make_ym_interval function

Creates an interval from days, hours, mins and secs.

Since: Databricks Runtime 10.0

Syntax

make_dt_interval( [ years [, months ] ] )

Arguments

  • years: An integral number of years, positive or negative

  • months: An integral number of months, positive or negative

Returns

An INTERVAL YEAR TO MONTH.

Unspecified arguments are defaulted to 0. If you provide no arguments the result is an INTERVAL '0-0' YEAR TO MONTH.

The function is equivalent to executing:

INTERVAL year YEARS + INTERVAL month MONTHS.

As such each unit can be outside of its natural range as well as negative.

Examples

> SELECT make_ym_interval(100, 5);
  100-5

> SELECT make_ym_interval(100, null);
  NULL

> SELECT make_ym_interval(0, 13);
  1-1

> SELECT make_ym_interval(1, -1);
  0-11