The TO_DATE function converts a character of the CHAR, VARCHAR, NCHAR, or NVARCHAR2 data type to a value of the date data type.
Syntax
TO_DATE(char [, fmt [, 'nlsparam' ] ])
Parameters
| Parameter | Description |
|---|---|
| char | The data of the CHAR, VARCHAR, NCHAR, or NVARCHAR2 character type. |
| fmt | The date and time format. |
| nlsparam | The value is implicitly specified by the nls_territory initialization parameter or explicitly specified by the nls_date_format parameter. |
Return type
The return type is the DATE type.
Examples
Execute the following statement:
SELECT TO_DATE('199912','YYYYMM'),TO_DATE('2000.05.20','YYYY.MM.DD'),
(DATE '2008-12-31') XXDATE,
TO_DATE('2008-12-31 12:31:30','YYYY-MM-DD HH24:MI:SS'),
(TIMESTAMP '2008-12-31 12:31:30') XXTIMESTAMP
FROM DUAL;
The following query result is returned:
+----------------------------+------------------------------------+---------------------+------------------------------------------------------+-------------------------------+
| TO_DATE('199912','YYYYMM') | TO_DATE('2000.05.20','YYYY.MM.DD') | XXDATE | TO_DATE('2008-12-3112:31:30','YYYY-MM-DDHH24:MI:SS') | XXTIMESTAMP |
+----------------------------+------------------------------------+---------------------+------------------------------------------------------+-------------------------------+
| 1999-12-01 00:00:00 | 2000-05-20 00:00:00 | 2008-12-31 00:00:00 | 2008-12-31 12:31:30 | 2008-12-31 12:31:30.000000000 |
+----------------------------+------------------------------------+---------------------+------------------------------------------------------+-------------------------------+