Dateadd Function; Examples Of Dateadd - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

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
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:
YEAR
MONTH
DAY
HOUR
MINUTE
SECOND
QUARTER
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
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

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')
YY and YYYY
M and MM
D and DD
HH
MI and M
SS and S
Q and QQ
WW and WK
"Numeric Value Expressions" (page
337). The type of the datetime_expr is returned,
265).
"Datetime Value Expressions" (page
257).
DATEADD Function
381

Advertisement

Table of Contents
loading

Table of Contents