ADD_MONTH Function

The ADD_MONTHS function adds a month value to the expression date_argument of DATE type, and it returns a DATE type value. If the day (dd) of the value specified as an argument exists within the month of the result value of the operation, it returns the given day (dd); otherwise returns the last day of the given month (dd). If the result value of the operation exceeds the expression range of the DATE type, it returns an error.

Syntax

ADD_MONTHS ( date_argument , month )

 

date_argument :

date

NULL

 

month :

integer

NULL

Example

--it returns DATE type value by adding month to the first argument

 

SELECT ADD_MONTHS(DATE '2008-12-25', 5), ADD_MONTHS(DATE '2008-12-25', -5);

  add_months(date '2008-12-25', 5)   add_months(date '2008-12-25', -5)

=======================================================================

  05/25/2009                         07/25/2008

 

 

SELECT ADD_MONTHS(DATE '2008-12-31', 5.5), ADD_MONTHS(DATE '2008-12-31', -5.5);

  add_months(date '2008-12-31', 5.5)   add_months(date '2008-12-31', -5.5)

===========================================================================

  06/30/2009                           06/30/2008

 

SELECT ADD_MONTHS(CAST (SYS_DATETIME AS DATE), 5), ADD_MONTHS(CAST (SYS_TIMESTAMP AS DATE), 5);

  add_months( cast( SYS_DATETIME  as date), 5)   add_months( cast( SYS_TIMESTAMP  as date), 5)

================================================================================

  07/03/2010                                     07/03/2010