locked
Date field incorrect for some users (CRM 2011 online) RRS feed

  • Question

  • After our upgrade to CRM 2011 online we have noticed a strange problem.  We have a custom entity with a date field (date only format).  When user X inputs a date, that date shows up as a day earlier for user Y (i.e. 3/2/11 would show up as 3/1/11).

    My guess is there is an issue/bug parsing the date as the field is probably still a date and time field on the backend.  Though both users are set to the same timezone under options, as this was my initial guess as to where the bug existed.

    Any input is appreciated.

    Nick


    Tuesday, March 22, 2011 9:48 PM

Answers

All replies

  • Hello Nick,

    Is the Date Format of your users set properly? Check this by going to File > Options > Formats Tab.


    Cornel Croitoriu - Senior Software Developer & Entrepreneur

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Biz-Forward.comCroitoriu.NET

    Wednesday, March 23, 2011 10:33 AM
  • Yes they are all on the same date format under the Formats tab.  The date formatting is correct, but the actual dates are not.

     

    Nick

    Thursday, March 24, 2011 10:08 PM
  • This is likely a timezone issue.  Date captures time as well so that means if you collect the date in EST it captures it as XX/X3/XX at 12:00AM.  When you look at that date in another timezone, it converts it.  So in CST it becomes 11:00PM which is on XX/X2/XX, the day before.

    At least this is how it works from my testing which is a bummer because now I need to figure out how to represent dates.

    Tuesday, October 11, 2011 9:10 PM
  • The dates in CRM are all stored in UTC time. Then when a user views a date attribute it will get converted to the user's timezone. Like Mike suggests, you should verify that all users are on the same timezone. To see the user's timezone you need to go to the personal options in the "General" tab.

    Each user must update its own time zone (you cannot do it on behalf of other users). Or you can bulk update everybody's timezone as mentioned here: http://gonzaloruizcrm.blogspot.com/2011/05/updating-another-users-preferences.html


    Gonzalo | gonzaloruizcrm.blogspot.com

    Wednesday, October 12, 2011 12:34 PM
    Moderator
  • I don't know if you still have that problem, but I noticed similar behavior with CRM 2011 UR 5 today in a test environment. I replicated the behavior on two different dev machines later.

    I have a custom entity with 4 date fields, all set to "Date Only"

    I'm in time zone GMT+1, so is my machine, and the server that runs CRM. The region on the server is Norway.

    However, all dates are the day before. I had a plugin that does something on the post-create of that entity, so I attached the debugger and stepped through the code. It turned out that CRM actually set those dates to 11 PM the day before. Today's date would be handled 11/14/2011 11:00:00 PM.

    I changed the field from Date Only to Date And Time, and set the date to todays date 3 PM. The result was that CRM handled the date as 11/15/2011 2 PM.

    Since a date field with date only sets the date to 00:00:00, that would explain why I'd got yesterday's date. The moment I changed my time zone to GMT, everything worked as it should. But I can't base my solution on setting an incorrect time zone for all users, so I need to investigate the issue further. If anyone have any suggestions I would be very grateful

    Tuesday, November 15, 2011 4:59 PM
  • With a bit more thinking, I realised all I have to do is to call DateTime.ToLocalTime() on my datetime object. But this came as a surprise to me, given the fact that there's a lot of scenarios where you need the actual local date when something happened (Such as a contract sign date), and not the UTC.
    Tuesday, November 15, 2011 5:27 PM
  • As you probably realise the problem is caused because the "date only" is in fact just a normal date/time. This causes problems across time zones and with daylight savings. There's a MS Connect issue about it here: http://connect.microsoft.com/dynamicssuggestions/feedback/details/641126/crm-dates-should-be-stored-as-dates-not-times-date-only (please vote).

    Because we wanted the real local date we ended up writing a plug-in that silently stores only the date part in a separate numeric field in the format YYYYMMDD when the actual date field changes. We can then use this for reporting/grouping etc.

    LJ

     


    Tuesday, November 15, 2011 5:52 PM
  • Tuesday, November 15, 2011 5:55 PM