web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Comparing Date Fields for Equality using fetchxml Issue

(0) ShareShare
ReportReport
Posted on by 2,665

Hi,

I am trying to find all the child records where the date field is not in sync with the parent's date field. Both the date fields are kept in sync all the time but some of the legacy data isn't. So, I tried advanced find but soon noticed there isn't 'Does not Equal' operator for date fields. I tried writing a sql query and convert it into fetchxml using xrmtoolbox but that isn't working either. I am getting the date-time format for the [datefield] is invalid or value is outside the supported range.

here is the xml that I converted from sql query which is causing the above error:

<fetch mapping="logical" version="1.0">
  <entity name="incident">
    <attribute name="title" />
    <attribute name="new_name" />
    <attribute name="new_datetime" />
    <order attribute="new_name" />
    <filter>
      <condition attribute="new_datetime" operator="ne" value="new_datetime" />
      <condition attribute="new_name" operator="eq" value="xxxx" />
    </filter>
    <link-entity name="new_details" from="new_eterid" to="incidentid" alias="B" link-type="inner">
      <attribute name="new_cosname" />
      <attribute name="new_datetime" />
    </link-entity>
  </entity>
</fetch>

Please let me know if there is a better approach or what could be wrong with my approach. Thanks for any help!
 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    You can't compare values in that way. What I would recommend - use SSIS+Kingway Soft to get all the data from CRM, process it using conditional split and put results for example to Excel or SQL.

    Good luck.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    I have doubt that date field does not support "eq" and "ne" , in that case you can retrieve all the child records using parent GUID and then using code loop through all child date (Convert all the date to string in similar format "21/10/2018" ) and compare with parent date(You need to convert similar format). In the loop you can add the unmatched data in a list or object.

    In addition you can also create text field to store date and compare them.

  • crmprogrammer2013 Profile Picture
    2,665 on at

    Thanks Andrew. I will try that but my end goal is to update those child records which aren't in sync with parent's date values. I usually run bulk workflow execution tool from xrmtoolbox to update or backfill in such scenarios.

    I am little confused as to how this can be done!

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    You can start here - www.youtube.com/watch

    Using the same SSIS you can not only load and analyze data but you can make updates as well.

    Feel free to ask questions if you have it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans