Usage Notes

Teradata Vantageā„¢ Data Types and Literals

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

If you specify the AT clause for a TIMESTAMP[(n)] without time zone target data type, the following table shows the result of the CAST function or Teradata conversion based on the various options specified. If the target precision is higher than the source precision, trailing zeros are added in the result to adjust the precision. If the target precision is lower than the source precision, an error is returned.

IF you specify... AND the data type of time_expression is... THEN...
AT LOCAL with or without TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement based on the current session time zone. A local timestamp value is formed from CURRENT_DATE (at the above time zone displacement) and the time portion of time_expression obtained after the previous adjustment. The result is this local timestamp value adjusted to UTC by subtracting the above time zone displacement.

This is the same as not specifying the AT clause.

AT SOURCE

(where SOURCE is a keyword and not a column reference)

WITH TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement of time_expression. A local timestamp value is formed from CURRENT_DATE (based on the time zone displacement of time_expression) and the time portion of time_expression obtained after the previous adjustment. The result is this local timestamp value adjusted to UTC by subtracting the time zone displacement of time_expression.
AT SOURCE

(where SOURCE is a keyword and not a column reference)

without TIME ZONE an error is returned.
AT SOURCE TIME ZONE WITH TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement of time_expression. A local timestamp value is formed from CURRENT_DATE (based on the time zone displacement of time_expression) and the time portion of time_expression obtained after the previous adjustment. The result is this local timestamp value adjusted to UTC by subtracting the time zone displacement of time_expression.
AT SOURCE TIME ZONE without TIME ZONE an error is returned.
AT expression

or

AT TIME ZONE expression

with or without TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement defined by expression.

A local timestamp value is formed from CURRENT_DATE at the above time zone displacement and the time portion of time_expression obtained after the above adjustment. The result is this local timestamp value adjusted to UTC by subtracting the above time zone displacement.

AT time_zone_string

or

AT TIME ZONE time_zone_string

with or without TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement based on time_zone_string. The time zone displacement is determined based on time_zone_string, CURRENT_TIMESTAMP AT '00:00', and the TIME value of time_expression at UTC.

A local timestamp value is formed from CURRENT_DATE at the above time zone displacement and the time portion of time_expression obtained after the above adjustment. The result is this local timestamp value adjusted to UTC by subtracting the above time zone displacement.

If you specify the AT clause for a TIMESTAMP[(n)] WITH TIME ZONE target data type, the following table shows the result of the CAST function or Teradata conversion based on the various options specified. If the target precision is higher than the source precision, trailing zeros are added in the result to adjust the precision. If the target precision is lower than the source precision, an error is returned.

IF you specify... AND the data type of time_expression is... THEN...
AT LOCAL with or without TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement based on the current session time zone. A local timestamp value is formed from CURRENT_DATE (at the above time zone displacement) and the time portion of time_expression obtained after the above adjustment. This resulting timestamp is adjusted to UTC, and the result value of the CAST at UTC is adjusted to the above time zone displacement.

If the data type of time_expression is without time zone, this is the same as not specifying the AT clause.

AT SOURCE

(where SOURCE is a keyword and not a column reference)

WITH TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement of time_expression. A local timestamp value is formed from CURRENT_DATE (based on the time zone displacement of time_expression) and the time portion of time_expression obtained after the previous adjustment. This resulting timestamp is adjusted to UTC, and the result value of the CAST at UTC is adjusted to the time zone displacement of time_expression.
AT SOURCE

(where SOURCE is a keyword and not a column reference)

without TIME ZONE an error is returned.
AT SOURCE TIME ZONE WITH TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement of time_expression. A local timestamp value is formed from CURRENT_DATE (based on the time zone displacement of time_expression) and the time portion of time_expression obtained after the previous adjustment. This resulting timestamp is adjusted to UTC, and the result value of the CAST at UTC is adjusted to the time zone displacement of time_expression.
AT SOURCE TIME ZONE without TIME ZONE an error is returned.
AT expression

or

AT TIME ZONE expression

with or without TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement defined by expression.

A local timestamp value is formed from CURRENT_DATE (at the above time zone displacement) and the time portion of time_expression obtained after the above adjustment. This resulting timestamp is adjusted to UTC, and the result value of the CAST at UTC is adjusted to the above time zone displacement.

AT time_zone_string

or

AT TIME ZONE time_zone_string

with or without TIME ZONE the source time_expression (in UTC) is adjusted by adding the time zone displacement based on time_zone_string . The time zone displacement is determined based on time_zone_string, CURRENT_TIMESTAMP AT '00:00', and the TIME value of time_expression at UTC.

A local timestamp value is formed from CURRENT_DATE (at the above time zone displacement) and the time portion of time_expression obtained after the above adjustment. This resulting timestamp is adjusted to UTC, and the result value of the CAST at UTC is adjusted to the above time zone displacement.