w3resource

Oracle TO_TIMESTAMP_TZ function

Description

TO_TIMESTAMP_TZ converts char of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype to a value of TIMESTAMP WITH TIME ZONE datatype.

The optional fmt specifies the format of char. If you omit fmt, then char must be in the default format of the TIMESTAMP WITH TIME ZONE datatype. The optional 'nlsparam' has the same purpose in this function as in the TO_CHAR function for date conversion.

Syntax:

TO_TIMESTAMP_TZ(char [, fmt [, 'nlsparam' ] ])

Parameters:

Name Description
char The CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype value to be converted.
fmt
(Optional)
Specifies the format of char. Default: Format of the TIMESTAMP WITH TIME ZONE.
nlsparam
(Optional)
Specifies the language in which month and day names and abbreviations are returned. This argument can have this form : 'NLS_DATE_LANGUAGE = language'.

Pictorial Presentation

Pictorial Presentation of Oracle TO_TIMESTAMP_TZ function

Examples: Oracle TO_TIMESTAMP_TZ function

The following statement converts a character string to a value of TIMESTAMP WITH TIME ZONE :

SQL> SELECT TO_TIMESTAMP_TZ('2015-02-01 12:00:00 -5:00',
    2     'YYYY-MM-DD HH:MI:SS TZH:TZM') FROM DUAL;

Sample Output:

TO_TIMESTAMP_TZ('2015-02-0112:00:00-5:00','YYYY-MM-DDHH:MI:SSTZH:TZM')
-----------------------------------------------------------------------
01-FEB-15 12.00.00.000000000 PM -05:00

Previous: TO_TIMESTAMP
Next: TO_DSINTERVAL



Follow us on Facebook and Twitter for latest update.