Amazon Athena:将 bigint 时间戳转换为可读时间戳

noo*_*erp 8 sql amazon-web-services presto amazon-athena

我正在使用 Athena 查询以 bigInt 格式存储的日期。我想将其转换为友好的时间戳。

我试过了:

    from_unixtime(timestamp DIV 1000) AS readableDate
Run Code Online (Sandbox Code Playgroud)

和

     to_timestamp((timestamp::bigInt)/1000, 'MM/DD/YYYY HH24:MI:SS') at time zone 'UTC' as readableDate
Run Code Online (Sandbox Code Playgroud)

我收到了两者的错误。我是 AWS 的新手。请帮忙!

Pio*_*sen 10

假设您有t表示“Java 时间戳”(自纪元以来的毫秒数)的值,您可以使用from_unixtime:

from_unixtime(timestamp / 1000e0)
Run Code Online (Sandbox Code Playgroud)

如果要丢弃时间戳值的毫秒部分,可以这样做:

from_unixtime(timestamp / 1000)
Run Code Online (Sandbox Code Playgroud)