The major pain for MS Dynamics CRM developers is to work with the DateTime field in CRM. MSD CRM doesn’t have a only Date field. This may not look as an issue when I say that CRM don’t have only date field, but due to the nature how CRM handles these DataTime fields, it becomes a challenge for CRM developers to work with it.
Consider a simple example, CSR is working in the IST time zone enters a value for the birthday field as 22nd Sept 1989. Due to the nature of CRM, this value is stored in a database as 21st Sept 1989 06:30 PM. There is no issue when any CSR working in the IST time zone checks the record as CRM will convert the value from UTC to IST and which will be correct value. But what if a CSC working in PST time zone checks the record? CRM will convert the same UTC value (09/22/2014 06:30 PM) to PST time zone which will be shown as 21st Sept 2014 11:30 AM. How can CRM change the birthday of a record?
This is just because there is no only Date field in CRM. CRM DateTime always comes with a time component. There is a setting in creating a DateTime field that defines date only, but all that does is default the time to midnight local time.
Below are a few points which if considered before implementing your logic about a DateTime field in CRM can avoid the errors.
- DateTime is saved in database as UTC time only
- DateTime in CRM UI is always shown based on user’s local time zone. This is true even if UI is only showing the date component. This leads to following effect:
- DateTime retrieved through CRM Web Services is always UTC time
- DateTime set through CRM Web Services is user’s local time zone by default
- Note that extra care must be taken to understand whether the call is done with the calling user or a service user
- DateTime set through CRM Web Services can be defined to be UTC instead
- DateTime queried directly from SQL table or base view returns UTC
- DateTime queried from filtered view returns users local time
Note: It is recommended that you set the timezone for Administrative User to GMT/UTC irrespective of that users actual timezone or server physical location as GMT/UTC is the base timezone for CRM.