car*_*ted 2 sql postgresql select timestamp date
我在postgres数据库中有一个时间戳字段.我想选择上个月内发生的所有日期.所以像select*from table where timestamp>(当前时间戳 - 1个月).
zer*_*kms 11
select * from table where timestamp > now() - interval '1 month'
Run Code Online (Sandbox Code Playgroud)
确切地说:
SELECT *
FROM tbl
WHERE ts_col > now() - interval '1 month'
AND ts_col <= now();
Run Code Online (Sandbox Code Playgroud)