devxlogo

Add Months to a Date in Oracle SQL

Add Months to a Date in Oracle SQL

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;

devx-admin

Share the Post: