DATEADD
Function
Returns a new date by adding a specified time interval to an existing date.
Syntax
DATEADD(date-part, number, date)
Parameters
-
date-part: text
One of the following predefined strings. Each date-part has abbreviated aliases that can be used in place of the longer names without affecting the behavior.year
,yy
,yyyy
quarter
,qq
,q
month
,mm
,m
dayofyear
,dy
,y
day
,dd
,d
week
,wk
,ww
weekday
,dw
hour
,hh
minute
,mi
,n
second
,ss
,s
millisecond
,ms
- number: integer
The value added to the specified part of the date. - date: text
A text value that can be parsed into a date/time.
Return Value
A string like "2016-07-23 21:13:23.350", calculated by adding number to the part of date that is specified by date-part.Example
-- Prints "2016-08-23 00:00:00.000".
PRINT DATEADD('month', 1, '2016-07-23');
-- Prints "2015-01-29 12:41:25.000".
PRINT DATEADD('day', -5, '2015-02-03 12:41:25');
-- Prints "2015-02-05 16:41:25.000".
PRINT DATEADD('hh', 52, '2015-02-03 12:41:25');