PL/SQL To_date

The TO_DATE function converts string datatype to a value of DATE datatype.

To_date syntax

TO_DATE( string, [ format_mask ], [ nls_param ] )

To_date example

 
select to_date('January 21, 2014, 09:00 P.M.', 'Month dd, YYYY, HH:MI P.M.') from dual;

Result: 21-JAN-2014 21:00:00


select to_date(sysdate, 'dd-mm-yyyy HH24:MI:SS') from dual;	

Result: 26-DEC-2014 13:31:02


select to_date('062614', 'MMDDYY') from dual;	

Result: 26-JUN-2014 00:00:00


select to_date('01/02/2014', 'dd/mm/yyyy') from dual;	

Result: 01-FEB-2014 00:00:00


select to_date('21032015142309', 'ddmmyyyyhh24miss') from dual;

Result: 21-MAR-2015 14:23:09