Date functions – add_months

The Oracle/PLSQL date function ADD_MONTHS adds exactly the specified number of months to the specified date. The number can be positive or negative.

Syntax:

ADD_MONTHS(DATE, number_of_months_to_add)

Example code:

SELECT SYSDATE, ADD_MONTHS(SYSDATE, 3)
FROM dual

sysdate add_months
————————————————-
12/31/2009 2:47:42 AM 3/31/2010 2:47:42 AM

SELECT SYSDATE, TRUNC(ADD_MONTHS(SYSDATE, -2))
FROM dual

sysdate add_months
———————————
12/31/2009 10/31/2009

Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

Filed Under: PLSQL - Date Manipulation

Tags:

RSSComments (0)

Trackback URL

Leave a Reply




If you want a picture to show with your comment, go get a Gravatar.