Neoview SQL Reference Manual (R2.3)
Interval Literals
• “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).
[-]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)]
start-field TO end-field
must be 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.
YEAR | MONTH | DAY | HOUR | MINUTE | SECOND [(fractional-precision)]
specifies the end-field. If the end-field is SECOND, it can have a
fractional-precision up to 6 digits. The fractional-precision is the number
of digits of precision after the decimal point. The default for fractional-precision
is 6.
start-field | SECOND [(leading-precision, fractional-precision)]
specifies the single-field. If the single-field is SECOND, the leading-precision
is the number of digits of precision before the decimal point, and the
fractional-precision is the number of digits of precision after the decimal point.
The default for leading-precision is 2, and the default for fractional-precision
is 6. The maximum for leading-precision is 18, and the maximum for
fractional-precision is 6.
See “Interval Data Types” (page 214) and “Interval Value Expressions” (page 223).
236 SQL Language Elements