ADD_MONTHS

2023-07-28 02:55:42  Updated

Purpose

ADD_MONTHS() returns the value of date plus n months.

Note

Different months have different numbers of days, so if the value of date is the last day of a month, the function returns the last day of the resulting month. For example, ADD_MONTHS returns February 29, 2020 for the date one month before March 31, 2020.

Syntax

ADD_MONTHS(date, n)

Parameters

Parameter Description
date A date. The parameter is of the DATE data type.
n An integer or any value that can be implicitly converted to an integer. It is of the NUMBER data type.
  • If n is negative, the function returns the value of date minus n months.
  • If n is positive, the function returns the value of date plus n month.

Return type

The return type is DATE.

Examples

Return the dates three months before and 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
Contact Us