将当前时间戳 UTC 转换为 CET
Convert Current Timestamp UTC to CET
我正在尝试找到一种方法将 current_timestamp 转换为不同的时区。
Simba Athena 中的函数 current_timestamp 默认给我 UTC 时间戳。
我想在 CET 时区获得相同的时间戳。请注意,我想在我的查询中自动执行此转换。
我尝试了 convert_timezone('CET', current_timestamp) 函数,但它在 AWS Athena
中无法识别
在更简单的工作中,我正在寻找 Presto 中 SQL 服务器函数 GETUTCDATE() 的替代品,除了我想获得 CET 时间戳。有什么建议吗?
current_timestamp
在 Trino(以前称为 Presto SQL)中 returns 根据当前会话时区的 timestamp with time zone
值。例如,如果客户端在 America/Los_Angeles
时区:
trino> select current_timestamp;
_col0
---------------------------------------------
2020-08-26 09:14:43.259 America/Los_Angeles
(1 row)
您可以使用 current_timezone()
查看会话的当前时区:
trino> select current_timezone();
_col0
---------------------
America/Los_Angeles
(1 row)
要将 timestamp with time zone
转换为另一个时区,您可以使用 AT TIME ZONE
语法:
trino> select current_timestamp at time zone 'America/New_York';
_col0
------------------------------------------
2020-08-26 12:18:37.901 America/New_York
(1 row)
我正在尝试找到一种方法将 current_timestamp 转换为不同的时区。
Simba Athena 中的函数 current_timestamp 默认给我 UTC 时间戳。 我想在 CET 时区获得相同的时间戳。请注意,我想在我的查询中自动执行此转换。
我尝试了 convert_timezone('CET', current_timestamp) 函数,但它在 AWS Athena
中无法识别在更简单的工作中,我正在寻找 Presto 中 SQL 服务器函数 GETUTCDATE() 的替代品,除了我想获得 CET 时间戳。有什么建议吗?
current_timestamp
在 Trino(以前称为 Presto SQL)中 returns 根据当前会话时区的 timestamp with time zone
值。例如,如果客户端在 America/Los_Angeles
时区:
trino> select current_timestamp;
_col0
---------------------------------------------
2020-08-26 09:14:43.259 America/Los_Angeles
(1 row)
您可以使用 current_timezone()
查看会话的当前时区:
trino> select current_timezone();
_col0
---------------------
America/Los_Angeles
(1 row)
要将 timestamp with time zone
转换为另一个时区,您可以使用 AT TIME ZONE
语法:
trino> select current_timestamp at time zone 'America/New_York';
_col0
------------------------------------------
2020-08-26 12:18:37.901 America/New_York
(1 row)