Time-Zone Independent Date Field in Dynamics CRM Online 2015

Time-Zone Independent Date Field in CRM Online 2015 Update

 Prior to CRM Online 2015 update 1, CRM saves date in UTC format in Database and show the local date time to user based on the login user’s time zone configuration. It works perfect if you have users around the world. However it might cause some confusions for below scenarios:

  • The exact date not depend on the time zone. Ex: birthday, Anniversary
  • The exact date time not depend on time zone. Ex: Hotel Check in/out Date and time
  • Data migration
  • System/Data Integration

With the latest CRM Online 2015 update release, Microsoft introduces the DateTimeBehavior property to define whether to store date and time values with or without time zone information. Followings are the definition for these three Behavior:

 

CRM Online Time Settings

CRM Online Time Settings

 

Member name and value Description
UserLocal
  • Stores the date and time value as UTC value in the system.
  • The retrieve operation returns the UTC value.
  • The update operation converts the UTC value to the current user’s time zone value, and then stores the updated value as is or as the equivalent UTC value depending on the kind (DateTimeKind) of the value specified for update. If the specified value is of UTC kind, it’s stored as is. Otherwise, the UTC-equivalent value is stored.
  • Retrieving the formatted value converts from UTC to the user’s current time zone based on the time zone and locale setting of the user.
  • For the OData endpoint, the attribute is exposed as DateTimeOffset.
  • This behavior is used for system attributes like CreatedOn and ModifiedOn, and cannot be changed. You should use this behavior for custom attributes where you want to store date and time values with the time zone information.
DateOnly
  • Stores the actual date value with the time value as 12:00 AM (00:00:00) in the system.
  • For the retrieve and update operations, no time zone conversion is performed, and the time value is always 12 AM (00:00:00).
  • Retrieving the formatted value displays the date value without any time zone conversion.
  • For the OData endpoint, the attribute is exposed as DateTimeOffset.
  • This behavior should be used for custom attributes that store birthdays and anniversaries, where the time information is not required.
TimeZoneIndependent
  • Stores the actual date and time values in the system regardless of the user time zone.
  • For the retrieve and update operations, no time zone conversion is performed, and actual date and time values are returned and updated respectively in the system regardless of the user time zone.
  • Retrieving the formatted value displays the date and time value (without any time zone conversion) based on the format as specified by the current user’s time zone and locale setting.
  • For the OData endpoint, the attribute is exposed as DateTimeOffset.
  • This behavior should be used for attributes that store information such as check in and check out time for hotels.

Hopefully you find it useful!
Thank you,
Zhe Chen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s