Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Setrange

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

    I have Input Parameter as Posting Date in Report . I want to implement SetRange on 2 fields. If user enters Posting Date = 01/04.2017..31/05/2017 then Table should display only those records where (Posting Date is >= & <= Input Date) and (ReceiptDt is >= & <= Input Date)) .

Thanks

*This post is locked for comments

  • mmv Profile Picture
    11,469 on at
    RE: Setrange

    Hi,

    If your "Posting Date" filter is from the DataSource (i.e. the actual field of the table), you may write the below code which doesn't require any variable:-

    Record.SETFILTER("Receipt Date",Record.GETFILTER("Posting Date"));

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,314 Super User 2025 Season 1 on at
    RE: Setrange

    The above solution will take care of both the cases.

  • jsshivalik Profile Picture
    3,099 on at
    RE: Setrange

    Hi

      My question is Do i need to create 2 separate variables or with POsting Date Filter it can be done. User can enter single Day or Range in Posting Date.

    Thanks

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,314 Super User 2025 Season 1 on at
    RE: Setrange

    If its a single day then you can use two satement -

    IF STRPOS(FORMAT(InputDate),'..') = 0 THEN BEGIN   //Take Care of multiple values

      Record.SETFILTER("Posting Date", '%1', InputDate);

      Record.SETFILTER("Receipt Date", '%1', InputDate);

    END ELSE BEGIN                                                            //Take Care if single value.  

      Record.SETFILTER("Posting Date", '%1..%2',0D,InputDate);

      Record.SETFILTER("Receipt Date", '%1..%2',0D,InputDate);

    END

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,314 Super User 2025 Season 1 on at
    RE: Setrange

    With your statement, it seems you are assuming that user will always enter a range in Input Date.

    You can start with an error message if user does not enter a range like -

    IF STRPOS(FORMAT(InputDate),'..') = 0 THEN

     ERROR('Input Date should contain date Range');

    After this what @hasitha says is correct. The Posting Date and Receipt date will be filter as you require.

  • jsshivalik Profile Picture
    3,099 on at
    RE: Setrange

    It can be range or it can be single day

  • jsshivalik Profile Picture
    3,099 on at
    RE: Setrange

    Hi

      Do i need to create 2 separate variables (Start Date or End Date)  or with Posting Date Filter alone it can be done.

    I have one Input Condition if that is true then i want to filter records with Receipt Date on POsting Date Range. User may whatever enter in Receipt Date.

    Thanks

  • Tina Menezes Profile Picture
    2,582 on at
    RE: Setrange

    Hi

    You can either user setrange or setfilter

    Rec.SETFILTER("Posting Date",'>=071417D&<=072117D');

    Rec.SETRANGE("Posting Date",071417D,072117D);

    This will filter and display only those records which have posting date >= 14th July 2017 and <= 21st July 2017

    Instead of passing the dates directly like how I have written above, you have to add your field values.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Setrange

    Input Date can be a range like 01042017..30042017 or a single day like 30042017.

  • jsshivalik Profile Picture
    3,099 on at
    RE: Setrange

    Hi

     What is Input Date . I am accepting Date in Posting Date. In Posting Date user can enter 01042017..30042017

    Thanks

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