Date and Time Field in MS CRM 2015

Here a new setting is introduced called “Behavior” for date/time fields in Dynamic CRM 2015, user can be able to set Date Time field with different time behaviors.

You can see the below image.


Following are the behaviors:

  • User Local
  • Date Only
  • Time-Zone Independent


1. User Local:

When the Date Time behavior is set as User Local and format is Date and Time then the time displayed will be as per the user time zone. For example you can find the below screen shots below.


In the above screen shot for "Visit Date” field we have set the date and time behavior as “User Local”.

So when this field is set it will be shown as per the user time zone settings as follows –



In the above two screen shots you can find that the “Visit Date” field displays different time for both users because they both are from different time zones. This emulates the behavior of all date/time fields in Dynamics CRM prior to these new enhancements. All existing date/time fields in CRM are set as User Local by default. You will need to go and manually edit the behavior of the field if you would like it to behave as any of the following two behavior types.

2. Date Only:

For date only field since only date is displayed it has no effect of the user time zone. There is no time conversion done to show this value on CRM form. It is stored just as is entered and returned when requested.



In the above two screen shots “Visit Date” field shows same date as 9/9/2015 but time is not showing.

But here both the users are from different time zones but then still it is displaying same date. This is the use of “Date only” behavior.

3. Time-Zone Independent:

In below screen shot you can find that the values for “Visit Date” field which is given as Time-Zone independent behavior. It shows same date time for both users although they lie in different time zones.


Note-1: When the behavior of a field is “Time-Zone Independent, “field values are displayed with no time zone conversion. The date and time values are stored and retrieved as specified in the UI and SDK. The behavior of this field can’t be changed once it’s saved.


Note-2: All values for this field are currently stored in the UTC time zone format. If you change the behavior of the field, the value will no longer be converted to the current user’s local time zone. As a result some date and time values may change, you should review all the dependencies of this field, such as business rules, workflows, and calculated or rollup fields, to ensure that issues won’t occur.


In the above two screen shots you can observe in the first screen shot we set as time zone (GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi format. And in the second screen shot we set time zone as (GMT-08:00) Pacific Time (US & Canada). Here we have to observe both users are in different places and using different time zones then also we get same date and time. So this is the use of Time-Zone Independent behavior.

By using below Code we can retrieve the exact date and time of the Record. Here we using this code in plugin. According to your requirement you can use.

DateTime EventDate = currentEntity.GetAttribureValue<DateTime>(“mtcem_visitdate”);

Guid _userId;

WhoAmIRequest systemUserRequest = new WhoAmIRequest();

WhoAmIResponse systemUserResponse = (WhoAmIResponse)service.Execute(systemUserRequest);

_userId = context.InitiatingUserId;

WhoAmIRequest req = new WhoAmIRequest();

WhoAmIResponse res = (WhoAmIResponse)service.Execute (req);

RetrieveUserSettingsSystemUserRequest reqU = new RetrieveUserSettingsSystemUserRequest();

reqU.ColumnSet = new ColumnSet(true);

reqU.EntityId = _userId;

RetrieveUserSettingsSystemUserResponse timeZone = (RetrieveUserSettingsSystemUserResponse)service.Execute(reqU);

EventDate = EventDate.AddMinutes(-((int)timeZone.Entity["timezonebias"]));


With these enhancements it would be a little easier to manage the date and time and avoid unnecessary conversions to get it to work.

About Apps Now

Apps Now offers latest reads on Microsoft Technologies and Business Applications in an easily understandable and digestible manner for you to drive some mileage out of it. Keep following Apps Now to learn new technologies and best coding practices.

See more blogs from Apps Now

No Comments

Add a Comment

  1. (max length 2000)
  2. captcha refresh captcha
Please Wait