You are here: Function Reference > Alphabetical Listing > D > DateAdd

DateAdd

Use this function to add a specified number of days, months, and/or years to a date.

Syntax

DateAdd (Date, Format, Days, Months, Years)

Parameter

Description

Date

Enter a date string. The system assumes your entry to be in the format specified in the Format parameter. The default is the current date.

Format

Enter a date format string that describes the contents of the Date parameter. The default is date format 1 (MM/DD/YY).

Days

Enter the number of days. The default is zero (0).

Months

Enter the number of months. The default is zero (0).

Years

Enter the number of years. The default is zero (0).

This function adds a specified number of days, months, and years to a given date. The result is formatted according to the Format parameter.

The Days, Months, and Years parameters can be negative or positive. If you enter a negative parameter, the system subtracts the specified days, months, or years.

You do not have to divide the values into components. For example, you can add 300 days and 40 months to a date. The result reflects the appropriate year, month, and day.

Note This function tells the system to add days, months, and years—in that order. For instance, if you tell the system to add one day and one year to the date 02/28/2007, the result is 03/01/2008—not 02/29/2008. To get 02/29/2008 as the result, you would use two calculations, first adding the year, then adding the day.

Example

Here are some examples (assume the current date is 07/01/09):

Function

Result

Explanation

Return(DateAdd

(Date( ), "1", 10))

07/11/2009

Defaults to the current date which is specified as Date( ) and adds 10 days.

Return(DateAdd

(02/01/09, , , 44))

10/01/2014

Uses the given date (02/01/09) and adds 44 months. (Note that if you enter "44" as a string, it is automatically converted to an integer.)

Return(DateAdd

("09/138", "I" , , , -3))

06/139

The given date (09/138) using date format I is May 18, 2009. Subtracting three years results in the date May 18, 2006. Because 2008 is a leap year, the correct day of the year (counting consecutively from January 1) is 139. The resulting date is returned in the same date format.

See also