Skip to content

TO_TIMESTAMP

TO_TIMESTAMP(‘char [, ‘format’ [, ‘nlsparam’ ] ])

Section titled “TO_TIMESTAMP(‘char [, ‘format’ [, ‘nlsparam’ ] ])”
  • ‘char’: This is the literal string that will be converted to an Oracle TIMESTAMP type. The string should represent a valid date and time.
  • ‘format’: Specifies the format that the ‘char’ string is in. This uses traditional date format models, with some additional flexibility to handle the fractional second precision up to nine decimal places that is available in the TIMESTAMP type.
  • ‘nlsparam’: This is an optional parameter that specifies the language in which month and day names and abbreviations are returned. It defaults to the value of the NLS_DATE_LANGUAGE parameter. This helps to deal with localization.
SELECT TO_TIMESTAMP('2022-01-01 11:30:45', 'YYYY-MM-DD HH:MI:SS') FROM dual;
01-JAN-22 11.30.45.000000000

The TO_TIMESTAMP function converts a string into a timestamp. In the example, the string ‘2022-01-01 11:30:45’ is being converted to a timestamp according to the format ‘YYYY-MM-DD HH:MI:SS’. The function is being called on the dummy table dual which is used for select operations where actually no data is retrieved from a table.