Neoview SQL Reference Manual (R2.4 SP2)
DATEADD Function
The DATEADD function adds the interval of time specified by datepart and num_expr to
datetime_expr. If the specified interval is in years or months, DATEADD normalizes the
result. See “Standard Normalization” (page 325). The type of the datetime_expr is returned,
unless the interval expression contains any time components, then a timestamp is returned.
DATEADD is a Neoview extension.
DATEADD(datepart, num_expr, datetime_expr)
datepart
is YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, QUARTER, WEEK, or one of the
following abbreviations:
YY and YYYY
YEAR
M and MM
MONTH
D and DD
DAY
HH
HOUR
MI and M
MINUTE
SS and S
SECOND
Q and QQ
QUARTER
WW and WK
WEEK
num_expr
is an SQL exact numeric value expression that specifies how many datepart units of time
are to be added to datetime_expr. If num_expr has a fractional portion, it is ignored. If
num_expr is negative, the return value precedes datetime_expr by the specified amount
of time. See “Numeric Value Expressions” (page 253).
datetime_expr
is an expression that evaluates to a datetime value of type DATE or TIMESTAMP. The type
of the datetime_expression is returned, unless the interval expression contains any time
components, then a timestamp is returned. See “Datetime Value Expressions” (page 245).
Examples of DATEADD
• This function adds seven days to the date specified in start_date
DATEADD(DAY, 7,start_date)
• This function returns the value DATE '2009-03-07'
DATEADD(DAY, 7 , DATE '2009-02-28')
• This function returns the value DATE '2008-03-06'
DATEADD(DAY, 7, DATE '2008-02-28')
• This function returns the timestamp '2008-03-07 00:00:00'
DATEADD(DAY, 7, timestamp'2008-02-29 00:00:00')
DATEADD Function 369