Dynamics CRM 2011 · Dynamics CRM 2013 · Dynamics CRM 2015 · Dynamics CRM 4.0

FetchXml Query Compare Dates

Working with datetime in CRM is rather confusing at times. Most of the time, I resort to querying everything as UTC. Same thing here with FetchXml query, simply change the value to a UTC format yyyy-mm-ddThh:mi:ss.mmmZ.

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="account">
    <attribute name="name" />
    <attribute name="modifiedon" />
    <attribute name="accountid" />
    <order attribute="name" descending="false" />
    <filter type="and">
      <condition attribute="modifiedon" operator="ge" value="2015-03-13T00:17:00.000Z" />

PS: even though its not obvious on Advanced Find, you can also use ge operator to compare dates.



2 thoughts on “FetchXml Query Compare Dates

    1. Hi Andreas,

      If the date/time that you are comparing is in local date/time, then most definitely yes. The format yyyy-mm-ddThh:mi:ss.mmmZ is defined as UTC date/time with no time zone offset. For more information, follow the link Date and Time Formats.

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