DateAdd

This function uses a specified time interval to modify a date.

Syntax

DateAdd(interval, number, date)

Parameters

interval
Required. String expression that is the interval you want to add. The following table shows the possible values of the interval parameter.
Setting
Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
m Minute
s Second

number
Required. Numeric expression that is the number of interval you want to add. The numeric expression can either be positive, for dates in the future, or negative, for dates in the past.
date
Required. Variant or literal that represents the date to which interval is added.

Return Values

Returns a Variant of subtype Date.

Remarks

Use DateAdd to add a specified time interval to a date or subtract a specified time interval from a date. For example, you can use DateAdd to calculate a date 30 days from today or a time 45 minutes from now. To add days to date, you can use Day of Year (y), Day (d), or Weekday (w).

DateAdd will not return an invalid date. The following code example adds one month to January 31.

NewDate = DateAdd("m", 1, "31Jan95")

In this case, DateAdd returns 28–Feb–95, not 31–Feb–95. If date is 31–Jan–96, it returns 29–Feb–96 because 1996 is a leap year and has an extra day in February.

If the calculated date would precede the year 100, an error occurs.

If number is not an integer, the decimal portion is removed before it is evaluated.