This function uses a specified time interval to modify a date.
DateAdd(interval, number, date)
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 |
Returns a Variant of subtype Date.
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, "31
–Jan
–95")
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.