|
<< Click to Display Table of Contents >> Navigation: Date / Time functions > DateAdd |
Description
Returns a Date value containing a date to which a specified time interval has been added.
Syntax
DateAdd(interval, number, date)
Parameters
Part |
Type |
Description |
interval |
String |
Required. String expression that is the interval of time you want to add.. |
number |
String |
Required. Numeric expression that is the number of intervals you want to add. It can be positive (to get dates in the future) or negative (to get dates in the past). |
date |
String |
Required. Date or literal representing date to which the interval is added. |
Settings
Currently supported interval argument:
Setting |
Description |
yyyy |
Year |
m |
Month |
d |
Day |
h |
Hour |
n |
Minut |
s |
Second |
Remarks
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 Weekday ("w").
The DateAdd function won't return an invalid date. The following example adds one month to January 31:
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.
If the calculated date would precede the year 100 (that is, you subtract more years than are in date), an error occurs.