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)

Is there a way to perform an Advanced Find where Date Field 1 Value > Date Field 2 Value?

(0) ShareShare
ReportReport
Posted on by 1,589

I have an entity, ace_job, with two date fields, ace_dateinprogress and ace_datecompleted. 

I have thousands of records where the date value contained ace_dateinprogress comes after the date value contained in ace_datecompleted. This is obviously a problem because ace_dateinprogress should never hold a date that comes before ace_datecompleted.

I need to perform an advanced find in the Dynamics 365 UI to retrieve all the records where ace_dateinprogress > ace_datecompleted, so I know which records need to be cleaned up and corrected. 

If I write the fetch xml outside of Dynamics 365 to retrieve these records I can do it as shown below.

<fetch mapping="logical" version="1.0">
  <entity name="ace_job">
    <all-attributes />
    <filter>
      <condition attribute="ace_dateinprogress" operator="gt" value="ace_datecompleted" />
    </filter>
  </entity>
</fetch>


My problem is that I need to do this inside of Dynamics 365 so I can bulk update the results. Unfortunately, there appears to be no way via advanced find to query "where Date in Progress > Date Completed"

JOBDATE.png

Is there a way to choose Date in Progress > Date Completed in the filter?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    David Jennaway Profile Picture
    14,065 on at

    Unfortunately you can't specify this directly in Advanced Find. One workaround could be to use a calculated field to get the difference between the two fields (using e.g. DiffInDays), then use Advanced Find to filter on the calculated field

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

    Hello Jim ,

    This is  one of the limitation of fetch XML , however I would suggest export all the data in an excel and do your operation in the excel what you want and then again import all the data.

    Before import all the data  you need to do bulk delete operation in Dynamics CRM based on your condition.

    Hope this helps .

  • ACECORP Profile Picture
    1,589 on at

    Thanks. I figured as much but was hoping there was a way around this in 365 version 9. I ended up using a regular SQL query against an Azure SQL replica to get the list of records that I need to work with. Lucky there are only 55, so I just created an Advance Find and set up an OR condition to grab each of those specific records. Now that I have all 55 returned in the advance find, I can bulk update them accordingly. If it returned 1000+ records I would have either used the calculated field + workflow or opted for SSIS. Deleting and re-importing isn't possible because that creates a whole different set of problems.

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