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

# months_sub

> Subtracts specified months from the date.

Subtracts specified months from the date.

## Syntax

```Haskell theme={null}
DATETIME months_sub(DATETIME expr1, INT expr2);
```

## Parameters

* `expr1`: the specified date. It must be of the DATETIME or DATE type.

* `expr2`: the month to subtract. It must be INT type.

## Return value

Returns a DATETIME value.

## Examples

```Plain Text theme={null}
select months_sub('2022-02-28 15:04:05', 1);
+--------------------------------------+
| months_sub('2022-02-28 15:04:05', 1) |
+--------------------------------------+
| 2022-01-28 15:04:05                  |
+--------------------------------------+

select months_sub('2022-02-28', 1);
+-----------------------------+
| months_sub('2022-02-28', 1) |
+-----------------------------+
| 2022-01-28 00:00:00         |
+-----------------------------+
```


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