try_make_interval function
Applies to: Databricks SQL
Databricks Runtime
Creates an interval from years, months, weeks, days, hours, mins, and secs, or returns NULL if the interval cannot be created.
Syntax
try_make_interval(years [, months [, weeks [, days [, hours [, mins [, secs] ] ] ] ] ] )
Arguments
years: An integral number of years, positive or negative.months: An optional integral number of months, positive or negative.weeks: An optional integral number of weeks, positive or negative.days: An optional integral number of days, positive or negative.hours: An optional integral number of hours, positive or negative.mins: An optional integral number of minutes, positive or negative.secs: An optional number of seconds with the fractional part in microsecond precision.
Returns
An INTERVAL, or NULL if the result overflows.
Unspecified arguments default to 0.
Examples
SQL
> SELECT try_make_interval(100, 11);
100 years 11 months
> SELECT try_make_interval(0);
0 seconds
> SELECT try_make_interval(2147483647, 0);
NULL