Oracle / PLSQL: TO_TIMESTAMP_TZ Function

This article is written about how to use the Oracle/PLSQL TO_TIMESTAMP_TZ characteristic with syntax and examples.

Description

The Oracle/PLSQL TO_TIMESTAMP_TZ function converts a string to a timestamp with time zone.

Syntax

The syntax for the TO_TIMESTAMP_TZ characteristic in Oracle/PLSQL is:

TO_TIMESTAMP_TZ( string1 [, format_mask] ['nlsparam'] )

Parameters or Arguments

string1 The string that will be transformed to a timestamp with time zone. format_mask Optional. This is the structure that will be used to convert string1 to a timestamp with time zone. It can be one or a aggregate of the following values: Parameter Explanation YYYY 4-digit year MM Month (01-12; JAN = 01). MON Abbreviated title of month. MONTH Name of month, padded with blanks to size 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). TZM Time quarter minute. TZH Time area hour.

Returns

The TO_TIMESTAMP_TZ feature returns a TIMESTAMP WITH TIME ZONE value.

Applies To

The TO_TIMESTAMP_TZ function can be used in the following variations of Oracle/PLSQL:

Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i

Example

Let’s appear at some Oracle TO_TIMESTAMP_TZ feature examples and explore how to use the TO_TIMESTAMP_TZ feature in Oracle/PLSQL.

For example:

TO_TIMESTAMP_TZ('2003/12/13 10:13:18 -8:00', 'YYYY/MM/DD HH:MI:SS TZH:TZM')

would return ’13-DEC-03 10.13.18.000000000 AM -08:00′ as a timestamp with time region value.

TO_TIMESTAMP_TZ('2003/DEC/13 10:13:18 -8:00', 'YYYY/MON/DD HH:MI:SS TZH:TZM')

would additionally return ’13-DEC-03 10.13.18.000000000 AM -08:00′ as a timestamp with time sector value.