Steve
Steve

Reputation: 313

Powershell dates to Sharepoint Dates

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

Upvotes: 2

Views: 6879

Answers (1)

pabdulin
pabdulin

Reputation: 35225

Sharepoint accepts iso date format which have format:

yyyy-MM-ddThh:mm:ssZ

in your example:

2011-05-06T07:52:12Z

Upvotes: 5

Related Questions