Are the DateTime objects returned from the Dynamics CRM web API always in UTC and where is that documented?
I am using the CRM SDK nuget package. I've read on several blogs (by CRM shops) that the CRM API always returns UTC DateTime objects and I have experienced that the DateTime.Kind is always UTC (from my testing) but I need to know for sure.
The CRM is 2015 if that matters.
I am calling a Dynamics CRM web services with the following code.
var querybyattribute = new QueryByAttribute()
{
EntityName = Opportunity.EntityLogicalName,
ColumnSet = new ColumnSet(true)//all columns
};
querybyattribute.Attributes.AddRange(attributeName);
querybyattribute.Values.AddRange(attributeValue);
And then calling RetreiveMultiple
EntityCollection entities;
using (var proxy = new ManagedTokenOrganizationServiceProxy(serviceManagement, credentials))
{
entities = proxy.RetrieveMultiple(query);
}
There are three different types of behavior for dates in CRM. Only two of them truly have the concept of timezone. The behavior of the three types can be found on MSDN, with the relevant parts copied here:
UserLocal (this is the only one available in CRM 2015 pre Update 1)
The retrieve operation returns the UTC value.
DateOnly
For the retrieve and update operations, no time zone conversion is performed, and the time value is always 12 AM (00:00:00).
TimeZoneIndependent
For the retrieve and update operations, no time zone conversion is performed, and actual date and time values are returned and updated respectively in the system regardless of the user time zone.
"In Web services (SDK), these values are returned using a common UTC time zone format. "
https://technet.microsoft.com/en-us/library/dn946904.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With