Tuesday, April 30, 2013

Convert Month to Date in oracle

 Convert Month to Date in oracle

            If user has number between 1 and 12, He can convert that number to Date

Syntax:
           to_date(day,fmt)  
        


SQL> select to_date(2,'mm') from dual;

TO_DATE(2,'mm')
--------------------
01-FEB-2014


SQL> select to_date(12,'mm') from dual;

TO_DATE(12,'mm')
--------------------
01-DEC-2014


If number exceeds 12. or less than 1, user gets following error message.


ERROR at line 1:
ORA-01843: not a valid month


Tags: Convert month  to date,convert month  to Date using To_Date function,oracle convert month  to date ,oracle convert month  to date using to_date,oracle convert month  to current month date.

No comments:

Post a Comment