Purpose
This function converts a string to the TIMESTAMP data type.
Syntax
TO_TIMESTAMP (char,[fmt],['nlsparam'])
Parameters
| Parameter | Description |
|---|---|
| char | A string of the CHAR, VARCHAR2, NCHAR, or NVARCHAR2 data type. |
| fmt | The format of the char parameter. This parameter is optional. If you omit this parameter, the char parameter must be in the default format of the TIMESTAMP data type. |
| nlsparam | You can specify the nlsparam parameter to customize the formatting and parsing rules for date, time, and numeric values in the TO_TIMESTAMP function. OceanBase Database currently supports only the nls_date_language parameter, which specifies the language for the returned month and day. The default value is AMERICA, and this value cannot be modified. |
Return type
TIMESTAMP
Examples
Convert the string 2021-11-11 11:11:11.11 to the TIMESTAMP data type.
obclient> SELECT TO_TIMESTAMP ('2021-11-11 11:11:11.11', 'YYYY-MM-DD HH24:MI:SS.FF')
FROM DUAL;
+-----------------------------------------------------------------+
| TO_TIMESTAMP('2021-11-1111:11:11.11','YYYY-MM-DDHH24:MI:SS.FF') |
+-----------------------------------------------------------------+
| 11-NOV-21 11.11.11.110000000 AM |
+-----------------------------------------------------------------+
1 row in set
