Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Static Date filter

(0) ShareShare
ReportReport
Posted on by 35

I am trying to create a report where the starting date is already coded and the ending date the user puts in and based on the ending date I get the report I want.  How can I code that?

*This post is locked for comments

  • Verified answer
    mjcjyk Profile Picture
    35 on at
    RE: Static Date filter

    Resolved my issue.  Thank you.

  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at
    RE: Static Date filter

    If you startDate hardcoded in program then you can write something like

    If EndDate <>0D THEN

     SETRANGE("Posting date",StartDate,EndDate);

  • ManishS Profile Picture
    80 on at
    RE: Static Date filter

    SETRANGE("Posting Date",0D, EndDate);

    This will show data till end date.

  • Suggested answer
    AJAnsari Profile Picture
    5,754 on at
    RE: Static Date filter

    You'll need to make one change: When working with the Date data type, a blank value would be 0D instead of ''

    The Setfilter part should be good (but missing an ; if there's no ELSE following it), but like I said, a little rusty here.

  • mjcjyk Profile Picture
    35 on at
    RE: Static Date filter

    Hi AJ,

    How would I code the End Date in the Report Request Page?  

    I have it as:

    IF EndDate <> '' THEN

    SETFILTER("Posting Date", '%1', EndDate)

    Would it be something like what I typed?

    Thank you,

  • Suggested answer
    AJAnsari Profile Picture
    5,754 on at
    RE: Static Date filter

    Hi mjcjyk,

    Not what you're asking for, but I have to start with: "hard-coding a date is a bad idea... why not prompt the user to enter it, or have a field on a setup table that can be populated with the starting date (and changed as/when needed)".

    Ok, now that that's off my chest, let's answer your question. Let's say you want your starting date to be locked in at 12/31/15. You'll need to set two variables in your report object of type Date, one for the Starting Date and one for the Ending Date. For the Starting Date (let's say you called the variable StartingDate), set it to your desired date with:

    StartingDate:=123115D;

    The Ending Date will likely be populated by the user in the Report Request Page, so make sure you have a field there feeding your EndingDate variable.

    It's been a while since I've written a single line of code in C/AL, but this should do the trick.

    Good luck. If you need more help with C/AL or Report writing, there are some nice e-Learning resources available through Microsoft CustomerSource (or PartnerSource, if you are a partner).

    I hope this helps. If my response has answered your question, please verify by clicking Yes next to "Did this answer your question?"

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans