Purpose
This function returns the date value that is n months after the date date.
Note
When the date value is the last day of a month, the function returns the last day of the resulting month. For example, if you use the ADD_MONTHS function to calculate the date one month before March 31, 2020, the function returns February 29, 2020.
Syntax
ADD_MONTHS(date, n)
Parameters
Parameter |
Description |
|---|---|
| date | The date. This parameter is of the DATE data type. |
| n | An integer or any value that can be converted to an integer. This parameter is of the NUMBER data type.
|
Return type
DATE
Example
Return the dates that are three months before and three months after the current date.
obclient> SELECT ADD_MONTHS(SYSDATE,-3),SYSDATE, ADD_MONTHS(SYSDATE,3) FROM DUAL;
+------------------------+-----------+-----------------------+
| ADD_MONTHS(SYSDATE,-3) | SYSDATE | ADD_MONTHS(SYSDATE,3) |
+------------------------+-----------+-----------------------+
| 17-AUG-21 | 17-NOV-21 | 17-FEB-22 |
+------------------------+-----------+-----------------------+
1 row in set
