Oracle PL/SQL - ADD_MONTHS function

ADD_MONTHS Function : 

Syntax : ADD_MONTHS (date,n); 
  • Return type of ADD_MONTHS is always a date.
  • n is a integer or any other value that can be converted to a integer
  • date can be either in a date format or any other value that can be converted to a date format.

Example 1:

SELECT ADD_MONTHS('02-MAR-2015',3) "RESULT" FROM DUAL

RESULT
-----------
02-JUN-2015

Example 2:

SELECT ADD_MONTHS('30-JAN-2015',1) "RESULT" FROM DUAL

RESULT
-----------
28-FEB-2015

Note : If the date is last day of the month or the resulting month has less number of days than the input date, then the resulting date is always the last day of the month


Oracle PL/SQL - CHR Function

CHR Function : 

Syntax : CHR (number);
               CHR (number USING NCHAR_CS)

  • In Oracle PL/SQL CHR function returns a ASCII equivalent of the input numeric value that is passed to the function.
  • The Function will return a national character if you specify USING NCHAR_CS
Example 1: 

SELECT CHR(72)||CHR(69)||CHR(76)||CHR(76)||CHR(79)"RESULT" FROM DUAL;
RESULT
-------
HELLO 
Example 2 :

SELECT CHR (50052 USING NCHAR_CS) "RESULT" FROM DUAL; 
RESULT 
-- ---
Ä