原生函数from_unixtime(BIGINT unixtime [, STRING format])使用时间戳为标准unix时间戳,单位必须是秒,但是一般在入库中,基础数据存入的都是13位的毫秒时间戳,例如startdate为BIGINT格式,转化为秒,startdate/1000,但结果变为DOUBLE格式,此时先用cast进行转换,
from_unixtime(cast(startdate/1000 as bigint)) as new_startdate #例如如下sql用例: select startdate,from_unixtime(cast(startdate/1000 as bigint),'yyyy-MM-dd HH:mm:ss') as new_startdate from sip where day=20210903 and hour='10' limit 10;
0 条评论