Add Days, Weeks, Months, and Years to a Date

From HotDocs Wiki

Jump to: navigation, search

You can add days, weeks, months, and years to a known date to determine a future date. For example, if you have a minor's birth date and you want to determine when the minor will turn 18 years old, you can simply add 18 years to the birth date. This is also very useful when determining dates for holidays.

The following computations show how to add days, weeks, months, and years to a Date variable.

Example:

In this example, "Date Var" is any Date variable. (You can also use the built-in TODAY variable if you want to add days, months, or years to the current date.)

//Add 30 days to a date
Date Var + 30 DAYS
 
//Add 6 weeks to a date
Date Var + ( 6 * 7 ) DAYS
 
//Add six months to a date
Date Var + 6 MONTHS
 
//Add 18 years to a date
Date Var + 18 YEARS

Note: You can also subtract days, weeks, months, and years from a date by replacing + with - in the script.