make_dt_interval function
Applies to: Databricks SQL
Databricks Runtime 10.4 LTS and above
Creates an interval from days, hours, mins and secs.
Syntax
make_dt_interval( [ days [, hours [, mins [, secs] ] ] ] )
Arguments
days: An integral number of days, positive or negativehours: An integral number of hours, positive or negativemins: An integral number of minutes, positive or negativesecs: A number of seconds with the fractional part in microsecond precision.
Returns
An INTERVAL DAY TO SECOND.
Unspecified arguments are defaulted to 0.
If you provide no arguments the result is an INTERVAL '0 00:00:00.000000000' DAY TO SECOND.
The function is equivalent to executing:
INTERVAL days DAYS + INTERVAL hours HOURS + INTERVAL mins MINUTES + INTERVAL secs SECONDS.
As such each unit can be outside of its natural range as well as negative.
Examples
SQL
> SELECT make_dt_interval(100, 13);
100 13:00:00.000000000
> SELECT make_dt_interval(100, null);
NULL
> SELECT make_dt_interval(0, 25);
1 01:00:00.000000000
> SELECT make_dt_interval(0, 0, 1, -0.1);
0 00:00:59.900000000