Hi
How to subtract No of days from Date
Thanks
*This post is locked for comments
Use Calcdate function
NewDate :=CALCDATE('-2D',Today);
In my case Days are stored in variable
NewDate := TODAY - 2
is the same as suggested by Amol above:
NewDate := CALCDATE('-2D', TODAY);
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Saurav.Dhyani 2 Super User 2025 Season 2
RK-25090803-0 1