presto unixtimestamp转标准日期


用到presto两个函数

1. from_unixtime

2.format_datetime

select
'1566748800000',
substr('1566748800000',1,10) as a,
from_unixtime(cast(substr('1566748800000',1,10) as int)) as b, -- 将13位毫秒级的unix timestamp截取到秒级别
format_datetime(from_unixtime(cast(substr('1566748800000',1,10) as int)),'yyyy-MM-dd')

 

转换结果

参考资料 https://prestodb.github.io/docs/current/functions/datetime.html

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM