DateAdd: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
DateADdd(''interval'',''number'',''date'') | |||
== Description == | |||
DateAdd returns the date which is obtained by adding a specified number of date intervals to a given date. The required parameter, interval, is a string expression that specifies the type of date interval to add, see Table 6 below. The required parameter, ''number'', is any numeric expression that specifies the number of intervals to add.The required parameter, ''date'', can be any expression that represents a date. | |||
'''Table 6: Interval Values''' | '''Table 6: Interval Values''' | ||
| Line 32: | Line 32: | ||
|} | |} | ||
== Example == | |||
<pre> | <pre> | ||
REM | REM DateAdd Example | ||
' | 'DateAdd adds date intervals to a date | ||
PRINT "+10 seconds:", | PRINT "+10 seconds:", DateAdd("s", 10, NOW) | ||
PRINT "-1 year:", | PRINT "-1 year:", DateAdd("yyyy", -1, NOW) | ||
</pre> | </pre> | ||
== Output == | |||
<pre> | <pre> | ||
| Line 48: | Line 48: | ||
</pre> | </pre> | ||
== Related Items == | |||
[[datediff|DATEDIFF]], [[datepart|DATEPART]] | [[datediff|DATEDIFF]], [[datepart|DATEPART]] | ||
[[Category:Language Reference]] | |||
Revision as of 20:35, 8 August 2012
DateADdd(interval,number,date)
Description
DateAdd returns the date which is obtained by adding a specified number of date intervals to a given date. The required parameter, interval, is a string expression that specifies the type of date interval to add, see Table 6 below. The required parameter, number, is any numeric expression that specifies the number of intervals to add.The required parameter, date, can be any expression that represents a date.
Table 6: Interval Values
| Value | Description |
|---|---|
| yyyy | Year |
| q | Quarter |
| m | Month |
| y | Day of year |
| d | Day |
| w | Weekday |
| ww | Week of year |
| h | Hour |
| n | Minute |
| s | Second |
Example
REM DateAdd Example
'DateAdd adds date intervals to a date
PRINT "+10 seconds:", DateAdd("s", 10, NOW)
PRINT "-1 year:", DateAdd("yyyy", -1, NOW)
Output
+10 seconds: 8/18/98 10:52:54 PM -1 year: 8/18/97 10:52:44 PM