> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MONTHS_BETWEEN

> Returns a signed fractional month difference, first minus second.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL temporal inputs yield NULL. NULL round\_off uses TRUE.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
months_between(first, second [, round_off])
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| first | DATE or TIMESTAMP | Yes | First temporal value. |
| second | DATE or TIMESTAMP | Yes | Second temporal value. |
| round\_off | BOOLEAN constant | No | Round result to eight decimals. Must be a constant argument. Default: TRUE. |

## Returns

* Type: DOUBLE
* NULL behavior: NULL temporal inputs yield NULL. NULL round\_off uses TRUE.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Exact result | Partial (Fractional results use floating-point arithmetic and optional eight-decimal rounding.) |

## Usage notes

* Same day-of-month or both month-end dates produce an integer difference, ignoring time-of-day.
* Otherwise fractions use a 31-day month and time-of-day difference.
* Supply a constant round\_off flag. A column with different flags per row is outside this form.
* Deterministic: Fractional results use floating-point arithmetic and optional eight-decimal rounding.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT months_between(DATE '2024-03-15',DATE '2024-01-15') AS result;
```

| result |
| - |
| 2.0 |

### Negative differences

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT months_between(DATE '2024-01-15', DATE '2024-03-15') AS months;
```

| months |
| - |
| -2 |

## Limitations

* Calendar calculations use the timestamp’s stored UTC time. They do not adjust it to the timestamp’s named time zone.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.