Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Report Query Correction

Posted on by 1,942

Hi all, 

I am trying to fetch record based on the 3 date fields which falls in last week from now.

Please provide me an SSRS expression or SQL Query for this requirement. 

*This post is locked for comments

  • Verified answer
    Vighnesh Profile Picture
    Vighnesh 1,942 on at
    RE: Report Query Correction

    Hi Sachith, thanks for responding. I've used both the queries to test and i had to modify your code to below updated one.

    <fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">

    <entity name="opportunity">

    <attribute name="name"/>

    <order descending="false" attribute="name"/>

    <filter type="and">

    <condition attribute="actualclosedate" operator="last-seven-days"/>

    <condition attribute="finaldecisiondate" operator="last-seven-days"/>

    <condition attribute="actualclosedate" operator="today"/>

    <condition attribute="finaldecisiondate" operator="today"/>

    </filter>

    </entity>

    </fetch>

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Report Query Correction

    Below is the SQL Query:

    SELECT Date1, Date2, Date3
    FROM Table_Name
    WHERE Date1 >= DATEADD(day,-7, GETDATE()) 
    OR Date2 >= DATEADD(day,-7, GETDATE()) 
    OR Date3 >= DATEADD(day,-7, GETDATE())


  • Suggested answer
    SCV Profile Picture
    SCV 1,004 on at
    RE: Report Query Correction

    Hi Vignesh,

    How about this?

    <fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">
    
    
    <entity name="opportunity">
    
    <attribute name="name"/>
    
    <order descending="false" attribute="name"/>
    
    <filter type="and">
    
    <condition attribute="actualclosedate" operator="last-seven-days"/>
    
    <condition attribute="finaldecisiondate" operator="last-seven-days"/>
    
    <condition attribute="createdon" operator="last-seven-days"/>
    
    </filter>
    
    </entity>
    
    </fetch>


    Replace the date fields with your date fields; also change the filter type to "or" instead of "and" if that is the requirement.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Report Query Correction

    Are you even trying to think of that?

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans