Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Add Months to a Date in Oracle SQL

Learn to easily add a number of months to a date in Oracle SQL with the ADD_MONTHS function.


advertisement

If you ever want to add a number of months to a date in Oracle SQL, you can use the ADD_MONTHS function. It's a simple function and takes two parameters — a date and the number of months.

To add 3 months to today's date:

SELECT ADD_MONTHS(SYSDATE, 3) FROM dual;


To add 12 months to a hire_date column:

SELECT ADD_MONTHS(hire_date, 12)
FROM employee;

You can also subtract months by supplying a negative number. To subtract 6 months from a hire date column:

SELECT ADD_MONTHS(hire_date, -6)
FROM employee;

 

Visit the DevX Tip Bank

 



   
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date