INTERVAL from a count of years, months, weeks, days, hours, minutes, and seconds. Each argument is optional and defaults to 0, so you can pass only the parts you need, by position or by name.
Syntax
Parameters
Pass arguments by position, by name (
days => 5), or both. Positional arguments come first and fill the parameters in the order listed. Each name may appear once.
Return type
INTERVAL. If any argument is NULL, the result is NULL.
Remarks
- Years become 12 months and weeks become 7 days. Hours, minutes, and seconds are added up into the time part, which is not converted into days:
MAKE_INTERVAL(hours => 30)returns30:00:00. Use JUSTIFY_HOURS to move whole days out of the time part. - Seconds are rounded to the nearest microsecond. A value exactly halfway between two microseconds rounds to the even one.
- The result must fit the interval: months and days each fit a 32-bit integer, and the time part fits 64-bit microseconds (about 292,000 years). A larger result raises
interval out of range. MAKE_INTERVALis compatible with PostgreSQL’smake_interval, with two differences. PostgreSQL’s integer parameters take onlyINTEGER; Firebolt also acceptsBIGINT. PostgreSQL 16 silently wraps a result that does not fit; Firebolt raises an error.- An
INTERVALcan be used in expressions and query results, but it can’t be stored in a table column.
Examples
Positional arguments1 year 2 mons 25 days 05:06:07.5
Named arguments
10 days 03:00:00
Per-row values
Arguments can be columns, so each row gets its own interval: