SQL/MX 2.x Reference Manual (H06.04+)
SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual—540440-003
6-44
Interval Value Expressions
Interval value expressions are built from operands that can be:
•
Integers
•
Datetime value expressions
•
Interval literals
•
Column references with datetime or interval values
•
Host variables of type INTERVAL
•
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
Datetime Value Expressions on page 6-39.
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.
numeric-primary is:
unsigned-numeric-literal
| column-reference
| numeric-type-host-variable
| dynamic parameter
| numeric-value-function
| aggregate-function
| sequence-function
| scalar-subquery
| CASE-expression
| CAST-expression
| (numeric-expression)
interval-qualifier is:
start-field TO end-field | single-field
start-field is:
{YEAR | MONTH | DAY | HOUR | MINUTE} [(leading-precision)]
end-field is:
YEAR | MONTH | DAY | HOUR | MINUTE | SECOND [(fractional-
precision)]
single-field is:
start-field | SECOND [(leading-precision,
fractional-precision)]