Skip to main content

Notifications

Microsoft Dynamics NAV forum
Answered

DateFilter

Posted on by Microsoft Employee

Hi experts ,

i want to take a report only for expired due date and remaining amount <>0 value i need to take 

i have used this code

SETRANGE("Document Type",custledger."Document Type"::Invoice);
SETAUTOCALCFIELDS("Remaining Amount");
SETFILTER("Due Date",'<%1',WORKDATE,Date2);
SETFILTER("Remaining Amount", '>0');

i got solution (please see below screen shot)

4848.st2.png

but my requirements is  i need to take a expired due date with this date to this date(19/04/2018..09/04/2018)

i have used this code

Date2 := 090418D;
EndDate:= WORKDATE;
Date1 :=190418D;
SETRANGE("Document Type",custledger."Document Type"::Invoice);
SETAUTOCALCFIELDS("Remaining Amount");
SETFILTER("Due Date",'<%1',WORKDATE,Date2);
SETFILTER("Remaining Amount", '>0');

SETRANGE("Due Date",Date2,EndDate);

but im getting this results (please see below screen shot)

st3.png

i want to only red color data with this filter

Date2 := 090418D;
EndDate:= WORKDATE;

SETRANGE("Due Date",Date2,EndDate);

please give any soution.

Thank you

  • RE: DateFilter

    The SETFILTER statement is incorrect because the Filter string '<%1' only contains a single substitution character therefore the variable Date2 is ignored.

    Secondly, the SETRANGE statement on the "Due Date" field removes the filter set by SETFILTER statement

    EndDate := CALCDATE(-1D,WORKDATE) //workdate less 1 day

    Date2 := 090418D

    SETRANGE("Due Date",Date2,EndDate);

  • Verified answer
    Andrey Baludin Profile Picture
    Andrey Baludin 3,941 on at
    RE: DateFilter

    Also

    SETRANGE("Due Date",Date1,CALCDATE('-1D',TODAY));

    will work

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,160 Most Valuable Professional on at
    RE: DateFilter

    SETFILTER("Due Date",'%1..%2',Date1,CALCDATE('-1D',TODAY));

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: DateFilter

    Hi Stefano,

    I want take data from lesser of today date

    if i use like that this is also showing error

    SETFILTER("Due Date",'%1..<%2',Date1,TODAY);

    please see this and give any solution

    Thank you

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,160 Most Valuable Professional on at
    RE: DateFilter

    Do you want to set a date filter from Date1 to TODAY?

    Then:

    SETFILTER("Due Date",'%1..%2',Date1,TODAY);

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: DateFilter

    Hi Stefano,

    Thank yo so much for your quick reply

    i want to set filter

    date1 := 09/04/2018;

    SETFILTER("Due Date",Date1,'<%1',TODAY); //(09/04/2018..19/04/2018)

    but its showing error.

    please give any solution.

    Thank you

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,160 Most Valuable Professional on at
    RE: DateFilter

    A filter for Due date less than TODAY is:

    SETFILTER("Due Date",'<%1',TODAY);

    P.S. remember that WORKDATE could be different that TODAY.

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,451 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,353 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans