Access: DateAdd Function

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

DateAdd ('m', 4, #01/22/2004# )       returns 05/22/2004 
DateAdd ('yyyy',3, #11/10/2003# )     returns 11/10/2006

VBA Code

Dim MyNumber As Integer 
MyNumber = DateAdd('d',45,#12/09/1998#)

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.

SELECT DateAdd('d',45, Now()) AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.