We’ve already covered some basic truths about CRM 2011 date and time. In this post, we’ll focus on how to avoid date-only fields from showing different dates in different time zones.
A common problem that arises unexpectedly for many CRM users is when a date-only field shows a different date for users in different time zones. When this happens, it is usually because CRM sets the default time of the date-only field to midnight and even though you specify “date only”, CRM stores a full date/time value. So, say a date is set for 10/1/2012 at 12 AM by a user in New York City. For users in Chicago the date translates into 9/30/2012 11PM. Therefore, when shown as date-only it will show a different day.
In this example, we have a field “Date Event Confirmed” (schema name “po_dateeventconfirmed”). To make sure the time for this field is set to noon, we can set the OnChange event for the field to call the setEventConfirmed() function which in turn calls setDateTime() to do the work of setting the date/time values. Here’s what happens.
- When the value in “Date Event Confirmed” changes, it triggers setEventConfirmed()
- Within setEventConfirmed(), it calls setDateTime() to set the value of the field “po_dateeventconfirmed” specifying 12 as the hour and 0 as the minutes.
- Within setEventConfirmed(), it then resets the value of the field to 12 PM/noon.
- Note: You’ll notice that if the value of the field is originally blank, it uses the current date and adjusts the time accordingly; if the value of the field has already been set, it will use the existing date but only change the hour and minutes.
Here’s the code:
Latest posts by JoeCRM (see all)
- How to Assign a Territory to a Lead in Dynamics CRM - May 17, 2013
- Out of the Box Report: Dynamics CRM User Summary - May 16, 2013
- Dynamics CRM / XRM Integration with GIS and PowerMap - May 15, 2013