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 :
Microsoft Dynamics NAV (Archived)

Last week filter

(0) ShareShare
ReportReport
Posted on by 1,893

Dear Experts,

how to write the filter for last week(previous week), want to see the sales orders of last one week on every Monday. i want to sent in my separate codeunit. 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    CALCDATE('-7D',TODAY) is 7 days before today.

    In alternative, you can use the Date virtual table in order to filter the period you need.

  • manish.yadav Profile Picture
    1,893 on at

    I want to find the all production order which are closed in last week. So I have created a separate codeunit but here I am unable to set the last week filter. My code is below:

    CLEAR(Mail);

    Mail.CreateMessage('Att India Limited','nav@att.com','nav.user@att.com','Last Week Closed RPO List.','',TRUE);

    Mail.AppendBody('Dear Sir / Madam');

    Mail.AppendBody('<br><br>');

    Mail.AppendBody('Please Find Closed RPO List in Last Week');

    Mail.AppendBody('<HR>');

    Mail.AppendBody('<table border="1">');

    Mail.AppendBody('<tr>');

    Mail.AppendBody('<th>RPO No.</th>');

    Mail.AppendBody('<th>Due Date</th>');

    Mail.AppendBody('</tr>');

    ProductionOrder.SETRANGE(Status,4);

    ProductionOrder.SETCURRENTKEY("Finished Date");

    //ProductionOrder.CALCDATE('-7D',TODAY));

    ProductionOrder.SETFILTER(FORMAT(CALCDATE('-7D',TODAY)));

    IF ProductionOrder.FINDFIRST THEN

    REPEAT

    Mail.AppendBody('<tr>');

     Mail.AppendBody('<td>'+FORMAT(ProductionOrder."No.")+'</td>');

     Mail.AppendBody('<td align="center">'+FORMAT(ProductionOrder."Due Date")+'</td>');

     Mail.AppendBody('</tr>');

    UNTIL(ProductionOrder.NEXT=0);

    Mail.AppendBody('</table>');

    Mail.AppendBody('<br>');

    Mail.AppendBody('Regards');

    Mail.AppendBody('<br>');

    Mail.AppendBody('ATT India Production Department');

    Mail.AppendBody(' ');

    Mail.AppendBody('<br><br>');

    Mail.AppendBody('<HR>');

    Mail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');

    Mail.Send;

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    You can use the following code (that uses the Date virtual table):

    Date.SETRANGE("Period Type",Date."Period Type"::Week);

    Date.SETFILTER("Period Start",'<=%1',TODAY);

    Date.SETFILTER("Period End",'>=%1',TODAY);

    if Date.FINDFIRST THEN

     currentWeek := Date."Period No."; //Here I'm using an integer variable to store the current week number

    Date.RESET;

    Date.SETRANGE("Period Type",Date."Period Type"::Week);

    Date.SETFILTER("Period Start",'<=%1',TODAY);

    Date.SETRANGE("Period No.",currentWeek-1); //Previous week

    if Date.FINDFIRST THEN

    begin

     //here I'm filtering all production order finished in the previous week

     ProductionOrder.SETFILTER("Finished Date",%1..%2',Date."Period Start",Date."Period End");

    end;

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 > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans