The purpose of TO_DATE in Oracle pl/sql is to convert char of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type to a value of DATE datatype.Or more generically the Oracle to_date function is used to change a test string (or variable) into an internal date format.
Syntax
to_date( stringDate, [ format_mask ], [ nls_param ] )
Where
stringDate : is the string to convert to date
format_mask : is the format that will be used to convert stringDate to a date.
nls_param : is the nls language used to convert stringDate to a date.
Examples:
SQL> select to_date('JAN/12/2009' ,'MON-DD-YYYY HH24:MI:SS') THE_DATE from dual; THE_DATE 1/12/2009 SQL> select to_date('20080312','YYYYMMDD') from dual; TO_DATE('20080312','YYYYMMDD') 3/12/2008 SQL> select to_date('20080312','YYYYDDMM') from dual; TO_DATE('20080312','YYYYDDMM') 12/3/2008 SQL> select to_date('2006/11/14 18', 'yyyy/mm/dd hh24') from dual; TO_DATE('2006/11/1418','YYYY/M 11/14/2006 6:00:00 PM SQL> SELECT TO_DATE('January 15, 1989, 11:00 A.M.', 'Month dd, YYYY, HH:MI A.M.','NLS_DATE_LANGUAGE = American')FROM DUAL; TO_DATE('JANUARY15,1989,11:00A 1/15/1989 11:00:00 AM SQL>
Also Read,
- ALTER TABLE to ADD PRIMARY KEY in Oracle| Oracle ALTER TABLE
- oracle date difference | date difference in sql an…
- DATE Data type in Oracle|Oracle Dates and Times|Dates in Oracle
- Formatting date in SQL (Oracle) -Simple date forma…
- Database Schema | Oracle Schema Objects | What is database schema?
- Autonomous Transactions in PL/SQL
- SQL – Transaction Statements -Transaction Manageme…
- Savepoints In SQL Transactions. – SAVEPOINT
- Oracle Tablespace, and Datafiles – Introduction
- Formatting date in SQL (Oracle) -Simple date forma…
- FINDING database objects, finding valid and INVALI…
Technorati Tags:
TO_DATE, oracle TO_DATE, pl/sql TO_DATE, sql TO_DATE, oracle date conversion, string to date
Pingback: Oracle Dates and Times |SYSDATE|CURRENT_TIMESTAMP |SYSTIMESTAMP |DBTIMEZONE |LOCALTIMESTAMP | SQL and PLSQL
Pingback: Oracle comparing dates : dates, oracle, date comparison in oracle pl/sql | SQL and PLSQL
Pingback: Using oracle date format |Using the DATE Format Mask in pl/sql | SQL and PLSQL
Pingback: Oracle PL/SQL: To_Timestamp Function | Datetime Format Models | SQL and PLSQL