PostgreSQL 时间戳转毫秒值并去除小数位
PostgreSQL About 447 words时间戳转毫秒值
使用extract
函数及epoch from
关键词。
select extract(epoch from (current_timestamp)) * 1000
输出
z-blog=# select extract(epoch from (current_timestamp)) * 1000;
?column?
-------------------
1613011422272.017
(1 行记录)
去除小数位
使用trunc
函数去除小数位(直接去除小数点后面几位,不做四舍五入处理)。
select trunc(extract(epoch from (current_timestamp)) * 1000);
输出
z-blog=# select trunc(extract(epoch from (current_timestamp)) * 1000);
trunc
---------------
1613011444878
(1 行记录)
Views: 6,835 · Posted: 2021-05-16
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...