TO_TIMESTAMP

TO_TIMESTAMP(x) converts the string x to a TIMESTAMP. The format is:

to_timestamp( x, [ format_mask ] [ 'nlsparam' ] )
  • x is the string to be converted to a timestamp.
  • format_mask, optional, is the format.

The format_mask list:

ParameterDescription
YYYY4-digit year
MMMonth (01-12; JAN = 01).
MONAbbreviated name of month.
MONTHName of month, padded with blanks to length of 9 characters.
DDDay of month (1-31).
HHHour of day (1-12).
HH12Hour of day (1-12).
HH24Hour of day (0-23).
MIMinute (0-59).
SSSecond (0-59).

SQL> select to_timestamp('2012/07/13 11:13:21', 'YYYY/MM/DD HH:MI:SS') from dual;

TO_TIMESTAMP('2012/07/1311:13:21','YYYY/MM/DDHH:MI:SS')
---------------------------------------------------------------------------
13-JUL-12 11.13.21.000000000 AM

SQL> select to_timestamp('2012/JUL/13 11:13:21', 'YYYY/MON/DD HH:MI:SS') from dual;

TO_TIMESTAMP('2012/JUL/1311:13:21','YYYY/MON/DDHH:MI:SS')
---------------------------------------------------------------------------
13-JUL-12 11.13.21.000000000 AM

SQL>
Home »
Oracle »
Conversion Functions » 

Related: