PatrickVerbeeten.com
Search this site Powered by Google
Something completely diferent my Photo album

Microsoft CRM Date values

CRM support user working in multiple time zones by storing alle date time values as UTC. This way the time can be easily adjusted to the users time zone setting. This article explains this in a bit more detail.

As for date values, some dates such as a birth date can be fixed regardless of time zone. CRM will still adjust these to the time zone, this may show as a full day difference in the interface. This article contains a plugin to allow you to use dates without timezone dependecies in CRM.

Crm and Time zones

A datetime value you enter in the CRM user interface such as 12-11-2008 15:00 will be stored differently according to your time zone settings. If you live in Amsterdam this will be stored as 12-11-2008 14:00 as both the correction for GMT+1. 4-8-2008 15:00 will be stored as 4-8-2008 13:00 because daylight savings is also applied. For values for which the time is important this typically not a problem.

If you are working with date only fields such as a birthdate a date (12-11-2008) can be stored as 11-11-2008 22:00. No if you live in London the value would be displayed as 11-11-2008 which appears a day early, actually it is just one hour but this is not visble.

Correcting the values

To make it easier to work with date only fields I have created a plugin which removes the time zone information.

There are two limitations to this plugin:

  • Values not processed by the update and/or create fields which still contain time zone information may show incorrectly if the retrieval is processed by this plugin.
  • For FetchXml responses only top level entity date fields are processed. Any date fields in link-entities will still retain their time zone information

Usage

To use this plugin register it in CRM (for example using my CrmTool). Create following steps for the following messages: create, update, retrieve, retrievemultiple and execute. For all messages except the Excute message you can specify a primary entity to run the plugin for just this entity type. The execute message (used for the Fetch statement, which is used by Advanced find) can only be registered to all entities.

The plugin steps do accept a configuration to allow filtering of attributes and entities for which to run. The configuration is in XML and must be formatted as follows:

<filter>
  <entity name="EntityName" >
    <attribute name="Attribute"/>
    <attribute name="Attribute"/>
    ...
  </entity>
  <entity name="EntityName" >
    ...
  </entity>
  ...
</filter> 

If no configuration is passed or no entities are specified the plugin will process attributes for any entity that triggers the update. If no attributes are specified for an entity all CrmDateTime attributes with format DateOnly will be processed, this information is retrieved from the Metadata service when needed.

To download this plugin (Source + Binary): Download the date correction PluginUtcDates.zip. This plugin is released under the LGPL v3.0 license, details are included in the download or can be found here.

Friday, September 12, 2008

©2010 Patrick Verbeeten, Disclaimer, Privacy Policy