SQL/MP Reference Manual
HP NonStop SQL/MP Reference Manual—523352-013
I-22
INTERVAL Literals
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.
An INTERVAL literal can contain a maximum of 18 digits, plus characters such as
hyphens (-) or colons (:) that separate the values of INTERVAL fields. The value can
be enclosed in either double quotation marks (shown in this diagram) or in single
quotation marks.
The start-field you specify must precede the end-field you specify in the list of
field name, and only end-field can use the precision option on FRACTION.
years
is an unsigned integer that specifies a number of years. It can have up to 18 digits,
minus the number of digits in the months field, if any. Negative values are allowed,
with the minus sign inside the quotes.
months
is an unsigned integer that specifies a number of months. Used as a starting field,
it can have up to 18 digits; as a nonstarting field, it must be in the range 0 through
11. Negative values are allowed, with the minus sign inside the quotes.
[ - ] INTERVAL { "y-m" } start-field [ (digits) ]
{ "d-t" }
[ TO end-field]
y-m is:
{ years[-months] }
{ months }
d-t is:
{ days:hours[:minutes[:seconds[.fraction]]] }
{ hours[:minutes[:seconds[.fraction]]] }
{ minutes[:seconds[.fraction]] }
{ seconds[.fraction] }
{ fraction }
start-field and end-field are:
{ YEAR }
{ MONTH }
{ DAY }
{ HOUR }
{ MINUTE }
{ SECOND }
{ FRACTION [ (precision) ] }