gpt4 book ai didi

sql - 如何将表示 EPOCH 时间的整数转换为 Athena (Presto) 中的时间戳?

转载 作者:行者123 更新时间:2023-12-04 01:08:52 26 4
gpt4 key购买 nike

我有一个表,其中日期时间存储为 varchar,但代表 EPOCH 时间(例如 1556895150)。如何让该值被识别为 Athena 中的时间戳/使用 Presto?像 dateadd 函数这样的东西可以工作,但 Athena 没有 dateadd(我设想像 dateadd('second',expressoin,'1970-01-01 00:00:00')。一个简单的 CAST(expressoin as type)没有在这里工作,因为 EPOCH 不是公认的日期时间数据类型。

最佳答案

您可以使用 from_unixtime() :

presto> select from_unixtime(1556895150);
_col0
-------------------------
2019-05-03 07:52:30.000
(1 row)

关于sql - 如何将表示 EPOCH 时间的整数转换为 Athena (Presto) 中的时间戳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56122925/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com