2

I have an old site that I am trying to convert to sharepoint. I have a database that stores the original upload date of the document. I need to get that date into a sharepoint column called "Original Upload". The "Original Upload" column is in a date/time format and only displays the date like "10/5/2009". I created a Powershell script to grab the date from the database and use it to change the "Original Upload" date in sharepoint. The problem is I keep getting a powershell error of "invalid date/time".

Powershell formats the date from the database as "Friday, May 06, 2011 7:52:12 AM". Sharepoint does not accept this date format. Sharepoint also does not accept strings. I was able to change the format of the powershell date to "5/6/2011" (the format on the sharepoint site), but it is converted from an object to a string, which doesn't work.

How do I convert a powershell date to "5/6/2011" and keep it as an object so Sharepoint will accept it?

Thanks

1 Answer 1

5

Sharepoint accepts iso date format which have format:

yyyy-MM-ddThh:mm:ssZ

in your example:

2011-05-06T07:52:12Z
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you so much! I have been trying to figure this out for the past 2 days. That worked perfectly.
Note the first 'mm' for month had to be uppercase to work for me: $updatedMembershipDate = (Get-Date $member["membershipdate"]).AddDays(1).ToString("yyyy-MM-ddThh:mm:ssZ");
@aalesund you are correct, fixed, thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.