Handling Date/Time fields in Microsoft Dynamics CRM 2015 Online Update 1

By | June 24, 2015

Introduction

Managing Date/Time fields in Dynamics CRM has not been easy especially when time zone come into picture and yet it is very critical to the application. Dynamics CRM being a global application was designed to support multiple timezones and the architecture design had a very noble thought behind it –

“No matter which timezone a user logs in and looks at a date/time value, the date/time should always be reflected in their own timezone”

To go ahead and support scenarios where on Date was required and not the time, they even created a format type to specify “Date-only” field.

To support this design architecture, the date time fields in the database are always stored in UTC format. The idea being the date/time could be then converted and shown in the time zone of the logged-in or the requesting user. You specify the timezone for each user in the User Options accessible through Options

Issues with storing in UTC

We sometimes only want CRM to store date as is, not really do the time conversion, no matter which time zone it is seen from, it should still display this static date as is. The date only field did not really achieve this. The date only is also stored as date with the time components as 12 am. Since it is UTC when viewed from another timezone, it would either go one day forward or a day back depending on the part of the world you are in.

Since it is stored in UTC any programmatic access to a date field would return a UTC value, which was not was really required and it required developers to add in date/time conversion code to use the date/time value retrieved from CRM.

New Enhancements

The product team has received well all the feedback sent around the issues with Date/time field type and with the Update 1 Online release, have brought about the following platform enhancements with the objective to resolve all issues around date/time fields.

They have now introduced a new setting called “Behavior” for date/time fields in Dynamic CRM 2015 Update 1, we are able to set DateTime field with different time behaviors.

Following are the behaviors:

  • User Local
  • Date Only
  • Time-Zone Independent

User Local:

When the DateTime behavior is set as User Local and format is Date and Time then the time displayed will be as per the user time zone. For example please find the screen shots below.


Here for “Interview date” field we have set the date and time behavior as “User Local”. So when this field will be set it will be seen as per the user time zone settings as follows –


 


In the above two screen shots you can find that the Interview Date field displays different time for both users as they both are from different time zones. This emulates the behavior of all date/time fields in Dynamics CRM prior to these new enhancements. All existing date/time fields in CRM are set as User Local by default. You will need to go and manually edit the behavior of the field if you would like it to behave as any of the following two behavior types.

Programmatically when you retrieve this value from CRM say for example as an input parameter of a workflow, the DateTime.Kind attribute is set to UTC.

Date Only:

For date only field since only date is displayed it has no effect of the user time zone. This is a true date only field. There is no time conversion done to show this value on CRM form. It is stored just as is entered and returned when requested.

Programmatically when you retrieve this value from CRM say for example as an input parameter of a workflow, the DateTime.Kind attribute is set to none.

Time-Zone Independent:

This DateTime field will be set irrespective of the time zone of user. So in below screen shot you can find that the values for “Relieving Date” field which is of Time-Zone independent behavior shows same date time for both users although they lie in different time zones.




Programmatically when you retrieve this value from CRM say for example as an input parameter of a workflow, the DateTime.Kind attribute is set to none.

Conclusion:

With these enhancements it would be a little easier to manage the dates and avoid unnecessary conversions to get it to work.

One Pic = 1000 words! Analyze data 90% faster with visualization apps!

Get optimum visualization of Dynamics 365 CRM data with –
Kanban Board – Visualize Dynamics 365 CRM data in Kanban view by categorizing entity records in lanes and rows as per their status, priority, etc.
Map My Relationships – Map My Relationships – Visualize connections and relationships between Dynamics 365 CRM entities or related records in a Mind Map view.