The ADD_MONTHS function returns a date value that is n months after date. If n is a negative value, this function returns a date value that is n months before date. Notice
Different months have different numbers of days. If date is the last day of a month, this function returns the last day of the resulting month. For example, if you use ADD_MONTHS 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 | A value of the DATE data type. |
| n | A value of the NUMBER data type. |
Return type
The return type is DATE.
Examples
Example 1 : In the following example, the date that is three months after the system date is queried.
Execute the following statement:
SELECT SYSDATE, ADD_MONTHS(SYSDATE,3) FROM DUAL;
The following result is returned:
+---------------------+-----------------------+
| SYSDATE | ADD_MONTHS(SYSDATE,3) |
+---------------------+-----------------------+
| 2020-03-26 12:21:40 | 2020-06-26 12:21:40 |
+---------------------+-----------------------+
Example 2 : In the following example, the date that is three months before the system date is queried.
Execute the following statement:
SELECT SYSDATE, ADD_MONTHS(SYSDATE,-3) FROM DUAL;
The following result is returned:
+---------------------+------------------------+
| SYSDATE | ADD_MONTHS(SYSDATE,-3) |
+---------------------+------------------------+
| 2020-03-26 12:21:04 | 2019-12-26 12:21:04 |
+---------------------+------------------------+