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

# months_add

> 向日期添加指定的月数，精确到月。

给日期添加指定的月数，精确到月。

## 语法

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

## 参数说明

`expr1`: 待添加月数的时间，支持的数据类型为 DATETIME 或 DATE。

`expr2`: 增加的月数，支持的数据类型为 INT。取值可以大于，等于或者小于 0。

## 返回值说明

返回值的数据类型为 DATETIME。

## 示例

```Plain theme={null}
select months_add('2019-08-01 13:21:03', 8);
+--------------------------------------+
| months_add('2019-08-01 13:21:03', 8) |
+--------------------------------------+
| 2020-04-01 13:21:03                  |
+--------------------------------------+

select months_add('2019-08-01', 8);
+-----------------------------+
| months_add('2019-08-01', 8) |
+-----------------------------+
| 2020-04-01 00:00:00         |
+-----------------------------+

select months_add('2019-08-01 13:21:03', -8);
+---------------------------------------+
| months_add('2019-08-01 13:21:03', -8) |
+---------------------------------------+
| 2018-12-01 13:21:03                   |
+---------------------------------------+
```


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