DATEADD function
Returns the date that the specified time interval has been added.
DateAdd(interval, number, date)
Parameters
Interval
Required option. A string expression that represents the time interval to add. For numeric values, see the "Settings" section.
Number
Required option. Numeric expression that represents the number of time intervals to add. Numeric expressions can be positive (get future dates) or negative numbers (get past dates).
Date
Required option. Variant or text to be added to the interval representation date.
Set up
The interval parameter can have the following values:
set |
description |
yyyy |
year |
q |
quarter |
m< /td> |
month |
y |
number of days in a year |
d |
|
w< /td> |
|
ww
week |
h |
hours |
n |
minutes |
s |
sec |
Description
You can add or subtract a specified time interval from a date by using the DateAdd function. For example, you can use DateAdd to calculate the date 30 days from today or 45 minutes from now. To add a time interval of "Day" to date , you can use the number of days per year (y), day (d), or number of days of the Week (W).
The DateAdd function does not return an invalid date. The following example adds one months to January 31, 95:
DateAdd("m", 1, "31-Jan-95")
In this example,DateAdd returns February 28, 95, not February 31, 95. If date is January 31, 96, it returns February 29, 96, because 1996 is a leap year.
If the calculated date is before 100 A.D., an error is generated.
If number is not a Long value, it is rounded to the nearest integer before being evaluated.