15.00 - TO_TIMESTAMP_TZ - Teradata Database

Teradata Database SQL Functions, Operators, Expressions, and Predicates

Product
Teradata Database
Release Number
15.00
Content Type
Programming Reference
Publication ID
B035-1145-015K
Language
English (United States)

TO_TIMESTAMP_TZ

Purpose  

Converts string_expr to a TIMESTAMP WITH TIME ZONE data type.

Syntax  

where:

 

Syntax element …

Specifies …

TD_SYSFNLIB

the name of the database where the function is located.

string_expr

a character argument.

If the conversion fails, TO_TIMESTAMP_TZ returns an error.

format_arg

a character argument.

format_arg specifies the format of string_expr.

format_arg does not convert data to any of the other datetime data types.

Any fractional seconds that are specified beyond 6 digits are truncated.

If format_arg is omitted, a default timestamp with time zone format of YYYY-MM-DD HH24:MI:SS.FF6 TZH:TZM is used.

For valid format_arg values, see “TO_DATE” on page 801.

If formal_arg is not valid, an error is returned.

If format_arg is NULL, NULL is returned.

ANSI Compliance

This is a Teradata extension to the ANSI SQL:2011 standard.

Invocation

TO_TIMESTAMP_TZ is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.

Argument Types and Rules

Expressions passed to this function must be a VARCHAR data type.

You can also pass arguments with data types that can be converted to the above type using the implicit data type conversion rules that apply to UDFs.

Note: The UDF implicit type conversion rules are more restrictive than the implicit type conversion rules normally used by Teradata Database. If an argument cannot be converted to the required data type following the UDF implicit conversion rules, it must be explicitly cast.

For details, see “Compatible Types” in SQL External Routine Programming.

Result Type

TO_TIMESTAMP_TZ is an overloaded scalar function whose return value data type is TIMESTAMP(6) WITH TIME ZONE.

Example  

The following query:

SELECT TO_TIMESTAMP_TZ ('January 15, 1989, 11:00 A.M.', 'Month dd, YYYY, HH: MI A.M.'); 

returns the result 1989-01-15 11:00:00.000000+00:00.