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)

Subtract Days

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

  How to subtract No of days from Date

Thanks

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Amol Salvi Profile Picture
    18,698 on at

    Use Calcdate function

    NewDate :=CALCDATE('-2D',Today);

  • jsshivalik Profile Picture
    3,099 on at

    Hi

     In my case Days are stored in variable

    Thanks

  • Hannes Holst Profile Picture
    5,767 on at

    NewDate := TODAY - 2

    is the same as suggested by Amol above:

    NewDate := CALCDATE('-2D', TODAY);

  • B Profile Picture
    on at

    Hi,

    As already suggested, you must use the CALCDATE function when you want to calculate a date based on another date.

    The first parameter is a DateFormula data type so the variable you use to store "No. of days" must be converted to a DateFormula.

    Note: to assign a value to a DateFormula data type, whether it is a field or a variable, you must use the EVALUATE Function.

    Your code would read something like this :

    NoOfDays := -3;  //Integer

    IF FORMAT(NoOfDays) <> '' THEN BEGIN

     EVALUATE(MyDateFormula,STRSUBSTNO('-%1D',FORMAT(ABS(NoOfDays))));

     NewDate := CALCDATE(MyDateFormula,TODAY);

     MESSAGE('%1',NewDate);

    END;

    Hope this helps,

    Bleika

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)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans