I have a table that contains 4 dates:
CREATE TABLE dates (
date date
);
11-mar-2008
25-now-2007
18-apr-2012
20-apr-2012
I need a query that returns all dates that are older than three-years-old. That should be the first 2 dates.
This doesn't work for me:
SELECT * FROM dates WHERE date = now()::-1095;
SELECT
*
FROM
dates
WHERE
date < now() - '3 years' :: interval;
Also, naming your column date
is not a good practice, as this is a reserved word in PostgreSQL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.