Advertisements
Home > CRM > CRM Date and Time field – Behaviors

CRM Date and Time field – Behaviors

Recently, I was asked a question in my blog on what is the significance of the different ‘Behaviors’ of ‘Date and Time’ field.

There are 3 different behaviors available for ‘Date and Time’ field.

Date and Time field behavior

Date and Time field behavior

User Local:

  • Time zone would be applied on this behavior. Field’s Date and time would be shown based on current user’s time zone.
  • ‘User Local’ behavior of a Field can be changed to other behaviors after field creation.
  • If the field behavior changed,
    • Behavior change takes affect only to the newly added/updated field values.
    • The existing field values remain in the database in the UTC time zone format.
  • To change the behavior of the existing field values from UTC to Date Only we would need SDK call (ConvertDateAndTimeBehaviorRequest)
  • Below is the sample code

var request = new ConvertDateAndTimeBehaviorRequest(){
Attributes = new EntityAttributeCollection() {
new KeyValuePair<string, StringCollection>(“account”, new StringCollection()
{ “new_sampledatetimeattribute” })
},
ConversionRule = DateTimeBehaviorConversionRule.SpecificTimeZone.Value,
TimeZoneCode = 190, // Time zone code for India Standard Time (IST) in CRM
AutoConvert = false // Conversion must be done using ConversionRule
};

// Execute the request
var response = (ConvertDateAndTimeBehaviorResponse)_serviceProxy.Execute(request);

 

    • Conversion rules:
      • SpecificTimeZone: Converts UTC value to a DateOnly value as per the specified time zone code.
      • CreatedByTimeZone: Converts UTC value to a DateOnly value that the user who created the record.
      • OwnerTimeZone: Converts UTC value to a DateOnly value that the user who owns the record.
      • LastUpdatedByTimeZone: Converts UTC value to a DateOnly value that the user who last updated the record
  • When you execute the ConvertDateAndTimeBehaviorRequest message, a system job (asynchronous operation) is created to run the conversion request.

Date Only:

  • Time zone isn’t applicable to this behavior. Field values are displayed without the time zone conversion.
  • The time portion of the value is always 12:00AM
  • This Behavior can’t be changed to other behavior types, once it’s set.
  • The Date Only behavior is good for cases when information about the time of the day and the time zone isn’t required, such as such as birthdays or anniversaries.

Time-Zone Independent:

  • Time zone isn’t applicable to this behavior. The field values are displayed without the time zone conversion.
  • This Behavior can’t be changed to other behavior types, once it’s set.
  • You can use this behavior when time zone information isn’t required, such as the hotel check-in time.

Refer MSDN article for more details.

🙂

Advertisements
Categories: CRM Tags: , ,
  1. Art Karp
    December 19, 2016 at 1:24 PM

    “The Date Only behavior is good for cases when information about the time of the day and the time zone isn’t required, such as such as birthdays or anniversaries”. This is not a good idea. As CRM stores the data as UTC and converts it back to the CRM users time zone. Depending on the CRM server time zone location set and the users time zone, it is possible that the date can change +/- one day. Also, since there are 26? valid time zones (overlapping in the Pacific), if CRM is defaulting to 12 PM as the time, this only allows for +/- 12 hours from GMT. This can also create a date change on what the user sees or is printed on a report. For all these reasons, it’s why Microsoft added the “Time Zone Independent” behavior.

    Always use “Time Zone Independent” behavior for a dates/time that must never change (e.g. contract expire date/time, date of birth).

    What is still missing is the ability to specify the time zone that the independent date/time represents. For example, if the date time is the expiry date of an insurance policy, for the contract you might need to track that it expires on December 31, 2017 at 12 AM US Eastern time. Currently you might need to add a separate text field to specify a time zone. Doing it this way insures that CRM never changes the date/time and anyone viewing the record understand exactly when the contract expires.

    Hope this helps,
    -Art

  2. Z
    January 14, 2017 at 2:12 AM

    How can we change a Time-Zone Independent field – that was changed incorrectly?

    Thank you for your response.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: