Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Unanswered

Fetch xml

Posted on by 55

Hi

how to write fetch xml query to retrieve data with specific future date

ex. select * contact where expirydate = Getdate()+40;

  • moelshimy Profile Picture
    moelshimy 55 on at
    RE: Fetch xml

    i mean is there any direct way to add getDate() + 40 in the fetch xml  query

  • NinoB Profile Picture
    NinoB 10 on at
    RE: Fetch xml

    Did you mean something like this?

    C#:

    DateTime today = DateTime.Now; // Replace with CRM Attribute Value

    DateTime expiredate = today.AddDays(40);

    var fetchXml = $@"

    <fetch top='50'>

     <entity name='contact'>

       <all-attributes />

       <filter type='and'>

         <condition attribute='ilume_testrollup_date' operator='eq' value='{expiredate}'/>

       </filter>

     </entity>

    </fetch>";

    Javascript:

    var expiredate = new Date(); Insert CRM Attribute Value

    expiredate.setDate(d.getDate() + 40);

    var fetchXml = [

    "<fetch top='50'>",

    "  <entity name='contact'>",

    "    <all-attributes />",

    "    <filter type='and'>",

    "      <condition attribute='ilume_testrollup_date' operator='eq' value='", expiredate, "'/>",

    "    </filter>",

    "  </entity>",

    "</fetch>",

    ].join("");

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans