gpt4 book ai didi

amazon-web-services - 如何在aws athena中查询unix epoch timestamp中的时间

转载 作者:行者123 更新时间:2023-12-05 03:39:30 25 4
gpt4 key购买 nike

我有一个简单的表,其中包含节点、消息、开始时间、结束时间 详细信息,其中开始时间和结束时间采用 unix 时间戳。我正在运行的查询是:

select node, message, (select from_unixtime(starttime)), (select from_unixtime(endtime)) from table1 WHERE try(select from_unixtime(starttime)) > to_iso8601(current_timestamp - interval '24' hour) limit 100

查询无效并抛出语法错误。

我正在尝试从表中获取以下信息:

  • 使用过去“n”小时或“n”天的开始时间和结束时间查询表,并以人类可读格式获取开始时间和结束时间的输出

  • 使用人类可读格式的特定日期和时间查询表格

最佳答案

您不需要“额外”选择,也不需要 where 子句中的 to_iso8601:

WITH dataset AS (
SELECT * FROM (VALUES
(1627409073, 1627409074),
(1627225824, 1627225826)
) AS t (starttime, endtime))

SELECT from_unixtime(starttime), from_unixtime(endtime)
FROM
dataset
WHERE from_unixtime(starttime) > (current_timestamp - interval '24' hour) limit 100

输出:

<表类="s-表"><头>_col0_col1<正文>2021-07-27 18:04:33.0002021-07-27 18:04:34.000

关于amazon-web-services - 如何在aws athena中查询unix epoch timestamp中的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68546217/

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