How SharePoint stores date/time values and why that matters?
Why is important how SharePoint stores date/time fields?
Let us start how SharePoint will store those values (date/time) => they are all stored in UTC time which means if I am in Delaware where our company is are in GMT-4 or 4 hours behind UTC.
For example, now is 4:25AM in Delaware:
But UTC is 08:25AM:
Why is this important?
In case that you instruct ReplaceMagic to keep last modified date of changed documents when we read that date which is stored in SharePoint in UTC zone and is, for example, 06/19/2020 06:35AM when we set back this value after making document changes SharePoint will automatically apply conversion of that date to UTC compared to value that we sent so, finally, date will be set to 06/19/2020 10:35AM.
To avoid this ReplaceMagic is reading value of "Last modified" field and before saving we are going to adjust it so that when SharePoint is converting to UTC before saving this value we get what was original value.
Example:
- We read 06/19/2020 06:35AM (which is UTC value stored in SharePoint)
- ReplaceMagic is making change of document and tries to save this timestamp back to original value
- As we are in Delaware and we have 4 time different when we sent 06/19/2020 06:35AM SharePoint will convert to UTC by adding 4 hours so it will save 06/19/2020 10:35AM. To fix this when we send date we will reduce it for 4 hours different and send 06/19/2020 02:35AM so after SharePoint converts value to UTC it will really save 06/19/2020 06:35AM.