Data import and ‘old’ dates

Running a data importing tool my team had developed I ran into this little gem: “Unhandled Exception: Microsoft.SharePoint.SPInvalidPropertyException: Date Times before 1/1/1970 are not supported”.

What the hell? I’ve entered dates prior to 1970 via the UI before. A quick search showed me this great post: Proper way to set DateTime format of a Sharepoint list item datetime property. Perfect.

I have one small addition to make to that. You can use the DateTime format string of “s” for ‘sortable’ date times.

fileToUpload.Properties["DateField"] = date.ToString("s");
Advertisements
This entry was posted in Development, SharePoint. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s