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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Fetch exactly 6 month older record from current date

(0) ShareShare
ReportReport
Posted on by

Hi,

I am having a date field in a custom entity. I need to fetch exactly the 6 months older record by comparing that date field with the current date. How can I build the fetchxml ?

I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Anandhcrm,

    You can resolve your problem by using the On or Before clause.

    pastedimage1665497615837v1.png

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Suggested answer
    Ray Profile Picture
    1,537 on at

    Hi,

    Another way is to use the "olderthan-x-months" operator,

    <condition attribute="<AttributeName>" operator="olderthan-x-months" value="6" />

    Here is the doc

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    You need to select below condition in your fetchXml.

    On or before - set value dynamically in your c# code by using below code

    AddMonths(your custom field date value, -6)

  • Anandhcrm Profile Picture
    on at

    no.. I need like this..

    for example, if I'm having the records in my entity like this..

    name,  joineddate

    aaa,    12/04/2022

    bbb,   13/04/2022

    ccc,    14/04/2022

    ddd,   13/04/2022

    my fetchxml will give the records having the date exactly 6 months old of joined date

    the result should be if the current date is 13/10/2022 are:

    bbb, 13/04/2022

    ddd, 13/04/2022

    result should be if the current date is 14/10/2022 are:

    ccc, 14/04/2022

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Where do you want use this logic ?

    In plugin, if yes then change operator to ON instead of on or before and pass the value as

    AddMonth(DateTime.now(),-6).ToShprtDateString();

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans