Which of the following way is correct to add x months to a month?

Options
- SELECT ADD_MONTHS('01-JAN-2005', 13) FROM dual;
- SELECT ADDMONTHS('01-JAN-2005', 13) FROM dual;
- SELECT ADD MONTHS('01-JAN-2005', 13) FROM dual;
- SELECT MONTHS_ADD(13,'01-JAN-2005') FROM dual;


CORRECT ANSWER : SELECT ADD_MONTHS('01-JAN-2005', 13) FROM dual;

Discussion Board
SELECT ADD_MONTHS('01-JAN-2005', 13) FROM dual;

The Oracle/PLSQL ADD_MONTHS function returns a date with a specified number of months added.

Syntax:

ADD_MONTHS( date1, number_months )

where,

date1: The starting date (before the n months have been added).
number_months: The number of months to add to date1.

Example

Let's look at some Oracle ADD_MONTHS function examples and explore how to use the ADD_MONTHS function in Oracle/PLSQL.

ADD_MONTHS('01-Aug-03', 3)
Result: '01-Nov-03'

ADD_MONTHS('01-Aug-03', -3)
Result: '01-May-03'

ADD_MONTHS('21-Aug-03', -3)
Result: '21-May-03'

ADD_MONTHS('31-Jan-03', 1)
Result: '28-Feb-03'

Prajakta Pandit 02-15-2017 01:17 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement