Casts a VARIANT value to the respective timestamp value:
AS_TIMESTAMP_LTZ (value with local time zone)
AS_TIMESTAMP_NTZ (value with no time zone)
AS_TIMESTAMP_TZ (value with time zone)
AS_TIMESTAMP_LTZ( <variant_expr> ) AS_TIMESTAMP_NTZ( <variant_expr> ) AS_TIMESTAMP_TZ( <variant_expr> )
Copy
Arguments¶variant_expr
An expression that evaluates to a value of type VARIANT.
The function returns a value of a timestamp type or NULL:
If the type of the value in the variant_expr
argument is a timestamp type, the function returns a value of same timestamp type.
If the type of the value in the variant_expr
argument doesn’t match the type of the output value, the function returns NULL.
If the variant_expr
argument is NULL, the function returns NULL.
Create a table and load data into it:
CREATE OR REPLACE TABLE as_timestamp_example (timestamp1 VARIANT); INSERT INTO as_timestamp_example (timestamp1) SELECT TO_VARIANT(TO_TIMESTAMP_NTZ('2024-10-10 12:34:56'));
Copy
Use the AS_TIMESTAMP_NTZ function in a query to cast a VARIANT value to a TIMESTAMP_NTZ value:
SELECT AS_TIMESTAMP_NTZ(timestamp1) AS timestamp_value FROM as_timestamp_example;
Copy
+-------------------------+ | TIMESTAMP_VALUE | |-------------------------| | 2024-10-10 12:34:56.000 | +-------------------------+
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4