Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

SSRS fetchxml date field with year parameter

Posted on by 7,316

Hi,

I need to add a filter to my fetchxml query in a ssrs report.

My report needs to filter based on year like 2020, 2019 etc.

I did put a filter with years in it but in the fetchxml query I have a date/time field to which I am trying to tie this selected year.

In sql, I have done something like this:

year(new_datetime)=@year

How do I achieve this in fetchxml? Can somebody please help?

Thanks.

  • meenoo Profile Picture
    meenoo 7,316 on at
    RE: SSRS fetchxml date field with year parameter

    Is there really no other approach?? This way we'd have to backfill many many records. I was hoping there'd be some approach that wouldn't require backfilling data. Any other ideas? Thanks.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SSRS fetchxml date field with year parameter

    Hi meenoo,

    It’s hard to directly intercept year part of the datetime field in fetchxml.

    You can use js code to copy year of the datetime field to the new created field, then use the new created field to compare with year parameter in fetchxml.

    1.Js code.

     

    function getYear(executionContext) {
        var formContext = executionContext.getFormContext();
        var dateFieldValue = formContext.getAttribute("new_testbirth").getValue();
        var year = dateFieldValue.getFullYear()   "";
        formContext.getAttribute("new_year").setValue(year);
    }

    2.Add the js web recsource to the datetime field onChange event.

    3.Test.

    pastedimage1603963803146v1.png

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans