gpt4 book ai didi

postgresql - 在postgresql中将日期转换为unix时间戳

转载 作者:行者123 更新时间:2023-11-29 11:12:07 33 4
gpt4 key购买 nike

我有一个表,其中 abc 列带有 unix 时间戳(例如 13898161481435),我想运行日期之间的选择。

这样做效率不高

where TO_CHAR(TO_TIMESTAMP(abc / 1000), 'DD/MM/YYYY') > '14/01/2014 00:00:00' and ..;

这将转换每条记录。

宁愿做类似的事情
其中 abc > ('14/01/2014 00:00:00' tobigint()) 和 abc < ...

但我找不到任何引用,尽管是相反的情况。

最佳答案

试试这个

WHERE abc > extract(epoch from timestamp '2014-01-28 00:00:00')

PostgreSQL Docs

关于postgresql - 在postgresql中将日期转换为unix时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21494665/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com