TO_TIMESTAMP_TZ function in oracle to convert a string to timestamp with time zone value.

By Santhosh N

This explains how to convert a string value to the timestamp with time zone value in oracle.

There is a conversion function in oracle by the name, TO_TIMESTAMP_TZ which converts the given string to timestamp along with time zone value included in it.

Syntax: TO_TIMESTAMP _TZ(str, [format], [Nls])

Here str is the string that needs to be converted to the timestamp with time zone value, optional format is the format mask that is used to convert the given string to the timestamp with time zone value, and optional Nls is the NLS language.

And, here are the different formats available
YYYY 4-digit year
MM     Month (01-12; JAN = 01).
MON     Abbreviated name of month.
MONTH Name of month, padded with blanks to length of 9 characters.
DD     Day of month (1-31).
HH     Hour of day (1-12).
HH12 Hour of day (1-12).
HH24 Hour of day (0-23).
MI     Minute (0-59).
SS     Second (0-59).

Ex1: SELECT TO_TIMESTAMP_TZ('2026/06/02 15:05:20', 'YYYY/MM/DD HH24:MI:SS') FROM dual;
This returns a “6/2/2010 3:05:20.000000000 PM -07:00” as result.

Ex2: SELECT TO_TIMESTAMP_TZ('02-JUN-2010 15:05:20', 'DD-MON-YYYY HH24:MI:SS') FROM dual;
This returns “6/2/2010 3:05:20.000000000 PM -07:00” as result.

Related FAQs

This explains how to convert a string value to the timestamp value in oracle.
This explains how to convert LONG or LONG RAW values to LOB values.
This explains how to convert a raw value to hexadecimal value in oracle.
This explains how to convert a rowid to varchar2 type in oracle.
This explains how to convert a char, varchar2, nchar or nvarchar2 value to rowid of a table in oracle database
This explains how to convert the both multi-byte and single-byte characters in oracle string to single-byte characters.
TO_TIMESTAMP_TZ function in oracle to convert a string to timestamp with time zone value.  (3479 Views)