Interval literals
Interval literals define an interval value in an expression.
Syntax 1: year-month class interval
INTERVAL ( inrep ) YEAR[(precision)] TO MONTH
|INTERVAL ( inrep ) YEAR[(precision)] TO YEAR
|INTERVAL ( inrep ) MONTH[(precision)] TO MONTH
Syntax 2: day-time class interval
INTERVAL ( inrep ) DAY[(precision)] TO FRACTION[(scale)]
|INTERVAL ( inrep ) DAY[(precision)] TO SECOND
|INTERVAL ( inrep ) DAY[(precision)] TO MINUTE
|INTERVAL ( inrep ) DAY[(precision)] TO HOUR
|INTERVAL ( inrep ) DAY[(precision)] TO DAY
|INTERVAL ( inrep ) HOUR[(precision)] TO FRACTION[(scale)]
|INTERVAL ( inrep ) HOUR[(precision)] TO SECOND
|INTERVAL ( inrep ) HOUR[(precision)] TO MINUTE
|INTERVAL ( inrep ) HOUR[(precision)] TO HOUR
|INTERVAL ( inrep ) MINUTE[(precision)] TO FRACTION[(scale)]
|INTERVAL ( inrep ) MINUTE[(precision)] TO SECOND
|INTERVAL ( inrep ) MINUTE[(precision)] TO MINUTE
|INTERVAL ( inrep ) SECOND[(precision)] TO FRACTION[(scale)]
|INTERVAL ( inrep ) SECOND[(precision)] TO SECOND
|INTERVAL ( inrep ) FRACTION TO FRACTION[(scale)]
- inrep is the representation of the interval value in normalized format (YYYY-MM or DD hh:mm:ss.fffff, depending on the interval class).
Usage
An interval literal is specified with the INTERVAL()
notation, and is typically
assigned in interval or datetime expressions, or to assign an INTERVAL
variable.
Example
MAIN
DEFINE i1 INTERVAL YEAR TO MONTH
DEFINE i2 INTERVAL HOUR(5) TO SECOND
LET i1 = INTERVAL( 345-5 ) YEAR TO MONTH
LET i2 = INTERVAL( 34562:22:33 ) HOUR(5) TO SECOND
END MAIN