[英]Convert TIMESTAMP_TZ to TIMESTAMP_NTZ in Snowflake SELECT
I have a tables in Snowflake that have fields of both TIMESTAMP_TZ
and TIMESTAMP_NTZ
types.我在 Snowflake 中有一个表,其中包含
TIMESTAMP_TZ
和TIMESTAMP_NTZ
类型的字段。
I would like to do a SELECT * FROM <table>
such that all TIMESTAMP_TZ
fields are read as TIMESTAMP_NTZ
(using TO_TIMESTAMP_NTZ()
function).我想做一个
SELECT * FROM <table>
以便所有TIMESTAMP_TZ
字段都被读取为TIMESTAMP_NTZ
(使用TO_TIMESTAMP_NTZ()
函数)。
How do I implement such a query?如何实现这样的查询?
Do you get any error when you use TO_TIMESTAMP_NTZ?使用 TO_TIMESTAMP_NTZ 时是否出现任何错误?
WITH sample_data AS (
SELECT '2020-11-22 20:00'::timestamp_tz A)
SELECT TO_TIMESTAMP_NTZ(A) FROM sample_data;
If it's just the matter of how it is displayed, you could do:如果只是显示方式的问题,您可以这样做:
alter session set TIMESTAMP_TZ_OUTPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF3';
select * from table_name;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.