Interval Subtype Units
The following tables lists subtype units that can be specified in an interval literal, divided into major categories:
Subtypes | Units | Notes |
---|---|---|
Millennium | mil | millennium |
|
millennia | mils |
||
Century | c | cent | century |
|
centuries
|
||
Decade | dec | decade |
|
|
||
Year
|
|
Julian year: 365.25 days |
ka
|
Julian kilo-year: 365250 days |
|
y | year | yr |
Calendar year: 365 days
|
|
years | yrs |
||
Quarter | q | qtr | quarter |
|
qtrs | quarters |
||
Month | mon | month | m |
Vertica can interpret |
mons | months |
||
Week
|
w | week |
|
weeks
|
Subtypes | Units | Notes |
---|---|---|
Day
|
d | day |
|
|
||
Hour | h | hour | hr |
|
hours | hrs |
||
Minute
|
min | minute | mm | m |
Vertica can interpret input unit |
mins | minutes
|
||
Second | s | sec | second |
|
seconds | secs |
||
Millisecond | millisecond | ms |
|
milliseconds | mseconds | msecs |
||
Microsecond | microsecond | us | usec |
|
microseconds | useconds | usecs |
Processing m Input
Vertica uses context to interpret the input unit m
as months or minutes. For example, the following command creates a one-column table with an interval value:
=> CREATE TABLE int_test(i INTERVAL YEAR TO MONTH);
Given the following INSERT
statement, Vertica interprets the interval literal 1y 6m
as 1 year 6 months:
=> INSERT INTO int_test VALUES('1y 6m'); OUTPUT -------- 1 (1 row) => SET INTERVALSTYLE TO UNITS; => SELECT * FROM int_test; i ----------------- 1 year 6 months (1 row)
The following ALTER TABLE
statement adds a DAY TO MINUTE
interval column to table int_test
:
=> ALTER TABLE int_test ADD COLUMN x INTERVAL DAY TO MINUTE; ALTER TABLE
The next INSERT
statement sets the first and second columns to 3y 20m
and 1y 6m
, respectively. In this case, Vertica interprets the m
input literals in two ways:
- For column i, Vertica interprets the
m
input as months, and displays 4 years 8 months. - For column x, Vertica interprets the
m
input as minutes. Because the interval is defined asDAY TO MINUTE,
it converts the inserted input value1y 6m
to 365 days 6 minutes:
=> INSERT INTO int_test VALUES ('3y 20m', '1y 6m'); OUTPUT -------- 1 (1 row) => SELECT * FROM int_test; i | x ------------------+----------------- 1 year 6 months | 4 years 8 months | 365 days 6 mins (2 rows)