---
title: "to_months function in Strata | Oplema"
description: "Turn a number into a month interval for date math, so that 5 becomes 5 months. Write it as to_months(integer) in a Strata Formula or Filter."
url: "https://oplema.com/docs/strata/functions/to-months"
updated: "2026-11-04"
---

# to\_months

Turn a number into an interval of that many months.

## Try an expression

In [Formula](https://oplema.com/docs/strata/prep/formula), enter the expression and set Output type to **VARCHAR**.

### Expression

```
to_months(5)
```

### Result

```
'5 months'
```

The expression returns `INTERVAL`. Formula stores it as `VARCHAR` in this example. To use your own data, replace the example values with column names. Keep format strings and other options as written.

Try it live in Formula

Result
| id | result |
| --- | --- |
| 1 | 5 months |

## Arguments and types

```
to_months(integer)
```

**integer**

Number

Supported signatures (2)

```
to_months(integer: BIGINT) → INTERVAL
to_months(integer: INTEGER) → INTERVAL
```

The result type can depend on the input types. See DuckDB for the full argument rules.

## Things to know

If the first argument is missing, the result is NULL.

## Related functions

[time\_bucket

Round a date or timestamp down to the start of a fixed-width bucket, such as every 2 days. Buckets count from 2000-01-03, or from 2000-01-01 for month and year buckets, unless you pass your own origin.

](https://oplema.com/docs/strata/functions/time-bucket)[to\_centuries

Construct a century interval.

](https://oplema.com/docs/strata/functions/to-centuries)[to\_days

Turn a number into an interval of that many days.

](https://oplema.com/docs/strata/functions/to-days)[to\_decades

Construct a decade interval.

](https://oplema.com/docs/strata/functions/to-decades)

[Browse dates & times](https://oplema.com/docs/strata/functions#dates-&-times) [DuckDB documentation](https://duckdb.org/docs/current/sql/functions/interval.html#to_monthsinteger)

Function metadata from DuckDB, used under the [MIT license](https://github.com/duckdb/duckdb/blob/v1.5.4/LICENSE).
