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");
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: Logo

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.