> ## 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.

# ADD_MONTHS

> Adds signed calendar months and clamps to month end.

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

NULL input or an unrepresentable output yields NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
add_months(value, months)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | DATE or TIMESTAMP | Yes | Starting value. |
| months | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | Signed number of months. Finite integer/floating month counts, or DECIMAL counts with up to 38 digits with a nonnegative scale. Floating and decimal fractional parts truncate toward zero. The truncated count must remain within signed INTEGER and the resulting date within calendar range. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: DATE
* NULL behavior: NULL input or an unrepresentable output yields NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Exact result | Yes |

## Units

* Input unit: Calendar months
* Output unit: DATE

## Usage notes

* Starting on the last day of a month preserves month-end in the target month.
* Fractional month counts are truncated toward zero. TIMESTAMP input returns a DATE, discarding the time of day.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Basic example

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT add_months(DATE '2024-01-31',1) AS result;
```

| result |
| - |
| 2024-02-29 |

### Move backwards across a year boundary

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT add_months(DATE '2024-01-31', -2) AS earlier_date;
```

| earlier\_date |
| - |
| 2023-11-30 |

## Limitations

* TIMESTAMP input produces DATE and loses its time of day. Query tools may still report TIMESTAMP.
* Keep month counts within the stated range. Very large counts and DECIMAL values with negative scale can overflow or produce unexpected results; an error or NULL result is not guaranteed.


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