1

I've a service that uploads documents to SharePoint Online and assigns the respective metadata to it. Everything works fine except the date fields that are always one day off.

Eg: If I assign the date 01/05/2016 while uploading the document, when I see it's properties on SharePoint Online it states 30/04/2016.

For the website my regional settings are the following:

Regional Settings Column settings are simple:

Column settings

In the background i'm parsing the date like this:

Return DateTime.Parse(strValue).ToUniversalTime().ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo)

Any suggestion on what am I doing wrong?

1
  • Remove the ToUniversalTime(). Use it like : Return DateTime.Parse(strValue).ToString(System.Globalization.DateTimeFormatInfo.InvariantInfo). ToUniversalTime converts date to UTC format. So maybe because of that the dates are off – Gautam Sheth Oct 17 '16 at 11:22
1

ToUniversalTime() converts your date to UTC format. Remove the section and it should work fine.

Remove the ToUniversalTime(). Use it like :

Return DateTime.Parse(strValue).ToString(System.Globalization.DateT‌​imeFormatInfo.Invari‌​antInfo)

ToUniversalTime converts date to UTC format. So maybe because of that the dates are off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.