SharePoint stores dates in UTC time

I was playing around with Search Based solutions in SharePoint 2010, inspired by the presentation of Scot Hillier (here). I really see a lot of potential for Search-Based solutions. Why bother with custom code, mucking around with timerjobs and such, trying to scrape together information from lists, sites and sitecollections, if you have all that information at your disposal in the search database?

So, to try my hand at a Search-Based solution, I thought I’d make a My Tasks webpart. A lot of customers would like to have a webpart that shows all tasks assigned to them, without them having to look through every site they are a member of.

Building the webpart wasn’t so difficult, but when I deployed the webpart, I was puzzled by the result. The webpart showed the three tasks I expected. What I didn’t expect were the deadlines (due date field).

Please note the deadline of the first task: 20-09-2011 (dutch date format: dd-mm-yyyy)

I was sure I entered the due date 21-09-2011, right??
Let me check the task…

What the …!?
Why is search (KeywordQuery) returning an incorrect date?
And this turned out to be the case for all date fields.

So, I decided to debug and investigate the search results up close, especially the date fields.

Hmmm…. Every datetime value I received in the results was 2 hours ‘earlier’…

A colleague of mine suggested reading this blog post about a similar problem with the SharePoint client object model. And then I finally realized SharePoint stores its datetime fields in UTC time. If you don’t look at the data from SharePoint through the UI (the UI corrects datetime values according to local time), you need to correct the datetime fields with the UTC offset you have locally.

Maybe this is all too familiar for some of you, but if you’re confronted with this problem for the first time, you’re kinda flabbergasted… 😯

So, using the DateTimeOffset, I modified the DateTime fields in de search results and…

I’m a happy camper again. 😀

4 thoughts on “SharePoint stores dates in UTC time

  1. Liakath

    Dear Sir,
    We also have the same problem .
    Our local time is PDT and results are showing in UTC formation. PDT is 7hrs behind UTC/GMT.

    Can you please let me know how and where you used the “DateTimeOffset”, to modify the date time fields in the search results.

    Eagerly waiting for your help.

  2. Ann


    I face a problem that sharepoint stores the date in all cases as “2015-04-19 21:00:00:000” into column ‘datetime1’ of AllUserData Table for item added on 2015-04-20 and at any from a particular application. The date is one day behind. Please help me solve this

    1. Ernst Wolthaus Post author

      Hi Ann,

      SharePoint registers DateTime in UTC format. There is nothing you can do about that.
      When SharePoint displays DateTime values in a standard SharePoint UI, SharePoint itself compensates this UTC ‘offset’.

      If you retrieve DateTime values through code (CSOM/JSOM), you have to correct for this UTC offset in your own code.
      This can be done by using the SharePoint or .Net timezone.


Leave a Reply

Your email address will not be published. Required fields are marked *