The ADD_MONTHS functions is use to fetch the date plus the months. Month is the number you have provided. In simple words it will fetch the data after (n) months. However we can fetch the data before (n) months by specifying - (Minus) before the number.
ADD_MONTHS function takes two parameters, one is date from which you need to fetch the month and the number as how many months after you wan to fetch the data.
Syntax is :-
ADD_MONTHS( DATE, N)
Example is :-
SELECT ADD_MONTHS(SYSDATE,1) AFT_MNT FROM DUAL;
SELECT ADD_MONTHS(TO_DATE('21-08-2014','DD-MM-YYYY'),1) AFT_MNT FROM DUAL;
SELECT ADD_MONTHS('21-AUG-2014',1) AFT_MNT FROM DUAL;
ADD_MONTHS function takes two parameters, one is date from which you need to fetch the month and the number as how many months after you wan to fetch the data.
Syntax is :-
ADD_MONTHS( DATE, N)
Example is :-
SELECT ADD_MONTHS(SYSDATE,1) AFT_MNT FROM DUAL;
SELECT ADD_MONTHS(TO_DATE('21-08-2014','DD-MM-YYYY'),1) AFT_MNT FROM DUAL;
SELECT ADD_MONTHS('21-AUG-2014',1) AFT_MNT FROM DUAL;
Using Minus :-
SELECT ADD_MONTHS(SYSDATE,-1) AFT_MNT FROM DUAL;
SELECT ADD_MONTHS(TO_DATE('21-08-2014','DD-MM-YYYY'),-1) AFT_MNT FROM DUAL;
SELECT ADD_MONTHS('21-AUG-2014',-1) AFT_MNT FROM DUAL;
Read Also:-