Neoview SQL Reference Manual (R2.4 SP2)

DATE_SUB Function
The DATE_SUB function subtracts the specified interval_expression from datetime_expr.
If the specified interval is in years or months, DATE_SUB 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.
DATE_SUB is a Neoview extension.
DATE_SUB (datetime_expr, interval_expression)
datetime_expr
is an expression that evaluates to a datetime value of type DATE or TIMESTAMP. See
“Datetime Value Expressions” (page 245).
interval_expression
is an expression that can be combined in specific ways with subtraction operators. The
interval_expression accepts all interval expression types that the Neoview database
software considers as valid interval expressions. See “Interval Value Expressions” (page 249).
Examples of DATE_SUB
This function returns the value DATE '2009-02-28'
DATE_SUB(DATE '2009-03-07', INTERVAL'7' DAY)
This function returns the value DATE '2008-02-29'
DATE_SUB(DATE '2008-03-07', INTERVAL'7' DAY)
This function returns the timestamp '2008-02-29 00:00:00'
DATE_SUB(timestamp '2008-03-31 00:00:00', INTERVAL '31' DAY)
This function returns the timestamp '2007-02-28 23:59:59'
DATE_SUB(timestamp '2008-02-29 23:59:59', INTERVAL '12' MONTH)
368 SQL Functions and Expressions