In Access, the DateAdd function Adds a specified time interval to a date.
The syntax for the DateAdd function is:
DateAdd ( interval, number, date )
You can use the DateAdd function to add a specified time interval to or subtract a specified time interval from a date. For example, you can use DateAdd to calculate a date 15 days from today or a time that is 30 minutes from now.
interval is the interval of time you want to add to date. The following is a list of valid interval values.
Interval | Description |
yyyy | Year |
q | Quater |
m | Month |
y | Day of year |
w | Weekday |
ww | Week |
h | Hour |
n | Minute |
s | Second |
number is the number of intervals you want to add to date. It can be positive (to get dates in the future) or negative (to get dates in the past).
date is the date to which the interval is added.
Examples
|
VBA Code
|
This example takes a date and, using the DateAdd function, displays a corresponding date a specified number of days in the future. Now the MyNumber variable would contain the value of ‘01.23.1999’.
SQL query
You can also use the DateAdd function in a query.
|