SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual540440-003
6-67
Interval Literals
Interval Literals
Considerations for Interval Literals
SQL/MP Considerations for Interval Literals
Examples of Interval Literals
An interval literal is a constant of data type INTERVAL that represents a positive or
negative duration of time as a year-month or day-time interval; it begins with the
keyword INTERVAL optionally preceded or followed by a minus sign (for negative
duration). You cannot include leading or trailing spaces within an interval string (within
single quotes).
start-field TO end-field
must be either year-month or day-time.The start-field you specify must
precede the end-field you specify in the list of field names.
{YEAR | MONTH | DAY | HOUR | MINUTE} [(leading-precision)]
specifies the start-field. A start-field can have a leading-
precision up to 18 digits (the maximum depends on the number of fields in
the interval). The leading-precision is the number of digits allowed in the
start-field. The default for leading-precision is 2.
[-]INTERVAL [-]{'year-month' | 'day:time'} interval-qualifier
year-month is:
years [-months] | months
day:time is:
days [[:]hours [:minutes [:seconds [.fraction]]]]
| hours [:minutes [:seconds [.fraction]]]
| minutes [:seconds [.fraction]]
| seconds [.fraction]
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)]