nak*_*120 6 time timestamp date bigint presto
我的数据集中有一个列,其数据类型为bigint:
Col1 Col2
1 1519778444938790
2 1520563808877450
3 1519880608427160
4 1520319586578960
5 1519999133096120
Run Code Online (Sandbox Code Playgroud)
如何将Col2转换为以下格式:
年月日hr:mm:ss
我不确定当前列的格式是什么,但我知道它应该是一个时间戳。
任何帮助将是巨大的,谢谢!
您是否尝试过使用类似的功能from_unixtime?您可以使用它将Unix时间转换为时间戳,然后可以使用所需的date_format方式显示它。请注意,在您的示例中,Unix时间以毫秒为单位,因此您可能需要先将其转换为毫秒。
我没有测试过,但我假设您的代码应如下所示:
date_format(from_unixtime(col2/1000), '%Y-%m-%d %h:%i:%s')
Run Code Online (Sandbox Code Playgroud)
请注意,它from_unixtime也接受时区。
请访问此页面以查看有关日期相关功能的更多详细信息:https : //docs.starburstdata.com/latest/functions/datetime.html