Warning: Invalid argument supplied for foreach() in /www/wp-content/plugins/elegant-custom-fonts/elegant-custom-fonts.php on line 420
Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

PowerObjects Blog 

for Microsoft Business Applications


CRM 2011 Date and Time: Prevent CRM from Displaying Incorrect Dates between Time Zones

Post Author: Joe D365 |

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.

One simple way to prevent this from happening is to add some JavaScript that will update any date-only date values to be set to some other hour like 8AM or noon instead of 12AM/midnight.

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 setSendEventNotice() function which in turn calls setDateTime() to do the work of setting the date/time values. Here's what happens.

  1. When the value in "Date Event Confirmed" changes, it triggers setSendEventNotice()
  2. Within setSendEventNotice(), it calls setDateTime() to set the value of the field "po_dateeventconfirmed" specifying 8 as the hour and 30 as the minutes.
  3. Within setSendEventNotice(), it then resets the value of the field to 12 PM/noon.
  4. 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:

JavaScript for fixing CRM 2011 date and time

One big advantage of using generic, re-usable Javascript functions is that they can be developed as multi-functional procedures. So, in this case, the setDateTime() function can be utilized by any other field, which may pass it any other field name and hour/minute combination. If we were to create the following function that is triggered OnChange of a "Send Event Notification" date field (schema name "po_sendeventnotice"), it would set the time of that field to 8:30 AM.

Happy CRM'ing!

By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

4 comments on “CRM 2011 Date and Time: Prevent CRM from Displaying Incorrect Dates between Time Zones”

  1. What about advanced find result ???

    Javascript is just useful for the form.

    Can anyone help please?

PowerObjects Recommends