This course is currently a work in progress. Please join the waitlist to receive regular updates.
Subtracting days from a date in apex
To subtract days from a Date variable, utilize the ApexaddDays()
method with a negative number (representing the number of days to subtract).
Following is an example of subtracting three
days from current date in apex.
Loading...
In the above example:
- The
System.today()
method is used to find the current date and assigned to the variable today. - The
addDays()
function is used with a negative parameter to find the third day before today.
Try It Yourself
Loading...