Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by 1,579

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

  • ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: Is there a way to perform an Advanced Find where Date Field 1 Value > Date Field 2 Value?

    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.

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Is there a way to perform an Advanced Find where Date Field 1 Value > Date Field 2 Value?

    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 .

  • Verified answer
    David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Is there a way to perform an Advanced Find where Date Field 1 Value > Date Field 2 Value?

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans