我在我的posgres数据库中有不同的时间戳。对于时间戳,我指的是自1970年以来的unix时间被保存为bigint。
现在我需要得到从1970年到现在的时间戳。例如: 1469059200000 (今日凌晨2:00应变为1469052000000 (今日凌晨00:00 ))
我已经在pgadmin中尝试过了
Select date_trunc('day', rp.timestamp) from rollup_days as rp但是刚刚得到了这个错误。错误:函数date_trunc(未知,bigint)不存在
发布于 2016-07-21 21:05:22
bigint不是“时间戳”,因此必须先将数字转换为日期,然后才能对其应用date_trunc():
Select date_trunc('day', to_timestamp(rp.timestamp))
from rollup_days as rp;要将时间戳转换回大整数,请使用extract()
Select extract(epoch from date_trunc('day', to_timestamp(rp.timestamp)))
from rollup_days as rp;https://stackoverflow.com/questions/38505028
复制相似问题