Interval Qualifier

Specifies how to interpret and format an interval literal for output, and, optionally, sets precision. Interval qualifiers are composed of one or two units:

unit[p] [ TO unit[p] ]

where:

If an interval omits an interval qualifier, the default is DAY TO SECOND(6).

Interval qualifiers are divided into two categories: day-time and year-month, as shown in the tables below.

Day-time interval qualifiers
Qualifier Description
DAY

Unconstrained

DAY TO HOUR Span of days and hours
DAY TO MINUTE Span of days and minutes
DAY TO SECOND Span of days, hours, minutes, seconds, and fractions of a second.
HOUR

Hours within days

HOUR TO MINUTE

Span of hours and minutes

HOUR TO SECOND

Span of hours and seconds

MINUTE

Minutes within hours

MINUTE TO SECOND

Span of minutes and seconds

SECOND

Seconds within minutes

Note: The SECOND field can have an interval fractional seconds precision, which indicates the number of decimal digits maintained following the decimal point in the SECONDS value. When SECOND is not the first field, it has a precision of 2 places before the decimal point.

 

Year-month interval qualifiers
YEAR

Unconstrained

MONTH Months within year
YEAR TO MONTH

Span of years and months

Note: Vertica also supports INTERVALYM, which is an alias for INTERVAL YEAR TO MONTH. Thus, the following two statements are equivalent:

=> SELECT INTERVALYM '1 2';
 ?column?
------------
 1 year 2 months

=> SELECT INTERVAL '1 2' YEAR TO MONTH;
    ?column?
-----------------
 1 year 2 months
(1 row)

Examples

See Controlling Interval Format.