Interval Value Expressions
•
"Considerations for Interval Value Expressions"
•
"Examples of Interval Value Expressions"
The operands of an interval value expression can be combined in specific ways with addition
and subtraction operators. In this syntax diagram, the data type of a datetime expression is DATE,
TIME, or TIMESTAMP; the data type of an interval term or expression is INTERVAL.
interval-expression is:
interval-term
| interval-expression + interval-term
| interval-expression - interval-term
| (datetime-expression - datetime-primary)
[interval-qualifier]
interval-term is:
interval-factor
| interval-term * numeric-factor
| interval-term / numeric-factor
| numeric-term
interval-factor is:
[+|-] interval-primary
interval-primary is:
interval-literal
| column-reference
| interval-type-host-variable
| dynamic parameter
| aggregate-function
| sequence-function
| scalar-subquery
| CASE-expression
| CAST-expression
| (interval-expression)
numeric-factor is:
[+|-] numeric-primary
| [+|-] numeric-primary ** numeric-factor
Interval value expressions are built from operands that can be:
•
Integers
•
Datetime value expressions
•
Interval literals
•
Column references with datetime or interval values
•
Dynamic parameters
•
Datetime or interval value functions
•
Aggregate functions, sequence functions, scalar subqueries, CASE expressions, or CAST
expressions that return interval values
For interval-term, datetime-expression, and datetime-primary, see
Expressions" (page
If the interval expression is the difference of two datetime expressions, by default, the result is
expressed in the least significant unit of measure for that interval. For date differences, the interval
is expressed in days. For timestamp differences, the interval is expressed in fractional seconds.
If the interval expression is the difference or sum of interval operands, the interval qualifiers of
the operands are either year-month or day-time. If you are updating or inserting a value that is
the result of adding or subtracting two interval qualifiers, the interval qualifier of the result
depends on the interval qualifier of the target column.
* interval-factor
210).
"Datetime Value
Expressions
213