问题
I have a timestamp field in a postgres database. I would like to select all dates that have happened within the last month. So something like select * from table where timestamp > (current timestamp - 1 month).
回答1:
select * from table where timestamp > now() - interval '1 month'
回答2:
To be precise:
SELECT *
FROM tbl
WHERE ts_col > now() - interval '1 month'
AND ts_col <= now();
来源:https://stackoverflow.com/questions/10942219/how-do-you-select-a-date-range-in-postgres