This function is used to calculate the date after a date value is increased by a specified number of months. That is, it calculates the data that is num_months after start_date.
add_months(string start_date, int num_months)
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
start_date |
Yes |
DATE or STRING |
Start date The following formats are supported:
|
num_months |
Yes |
INT |
Number of months to be added |
The date that is num_months after start_date is returned, in the yyyy-mm-dd format.
The return value is of the DATE type.
The value 2023-05-26 is returned.
select add_months('2023-02-26',3);
The value 2023-05-14 is returned.
select add_months('2023-02-14 21:30:00',3);
The value NULL is returned.
select add_months('20230815',3);
The value NULL is returned.
select add_months('2023-08-15 20:00:00',null);