d = DateAdd(interval, number, date)
|interval||(Variant) String expression that is the interval you want to add:|
yyyy - year
q - Quarter
m - month
y - day of year
d - day
w - day of the week
ww - week of year
h - hour
n - minute
s - second
|number||(Variant) 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||(Variant) Variant or literal representing the date to which interval is added.|
You can use the DateAdd function to add 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 day of the week ("w").
The DateAdd function won't return an invalid date. The following example adds one month to January 31:
NewDate = DateAdd ("m", 1, "31-Jan-2007")
In this case, function returns 28-Feb-2007, not 31-Feb-2007. If date is 31-Jan-2008, it returns 29-Feb-2008 because 2008 is a leap year.
If number isn't a Long value, it is rounded to the nearest integer before being evaluated.