This course is currently a work in progress. Please join the waitlist to receive regular updates.

Adding days to a date variable in apex

Apex date class provides the addDays() method to add a specific number to a given date. This method is very useful when doing date comparisons in apex.

Following is an example of adding three days to 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 to find the third day from today.
  • The addDays() function takes an integer input parameter .

Try It Yourself

Loading...