---
title: make_ym_interval function
description: Learn the syntax of the make\_ym\_interval function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/make_ym_interval
---

# `make_ym_interval` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime 10.4 LTS and above

Creates an year-month interval from `years` and `months`.

## Syntax

```
make_ym_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.

If the result overflows, Databricks raises [INTERVAL\_ARITHMETIC\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/interval-arithmetic-overflow-error-class.md).

## Common error conditions

* [INTERVAL\_ARITHMETIC\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/interval-arithmetic-overflow-error-class.md)

## Examples

```sql
> 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

> SELECT make_ym_interval(178956970, 8);
  Error: INTERVAL_ARITHMETIC_OVERFLOW
```

## Related functions

* [`make_dt_interval` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/make_dt_interval.md)
* [`make_date` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/make_date.md)
* [`make_timestamp` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/make_timestamp.md)
