0

I have just created list and in that list I create a datetime field, and I developed a C# program to get the list data, but when my program get datetime field value, have a wrong, in my sharepoint list, the datetime value is 2017/4/14 00:00, but in my program, the value is 2017/4/13 5:00 PM. I've searched on google so many times but have no result. Do anyone know about this problem? Please explain for me. Thanks!

6
  • Do you use Convert.ToDateTime(item[dateField]) or what? Apr 14 '17 at 4:56
  • yes, I did, but have no result.
    – GIANGPZO
    Apr 14 '17 at 6:20
  • Most likely a timezone difference between Server and Client you have to deal with programmatically Apr 14 '17 at 7:31
  • @Danny'365CSI'Engelman the timezone is the same in both Server and Client.
    – GIANGPZO
    Apr 14 '17 at 8:32
  • TimeStamp difference? SharePoint starts counting at 31/12/1899 your C# code at 1/1/1900? Apr 14 '17 at 11:17
0

I spent a few days to find out the problem. Finally, I understanded the mechanism of saving datetime in SQL Server of Sharepoint: Sharepoint used the UTC timezone to store datetime value in Sql server (whatever your timezone is). Althought my timezone is UTC+7, but in SQL sever is UTC, so when C# client code access sql server to get data, it got the datetime value in UTC timezone.

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.