PostgreSQL: get rows from a table 5 minutes ago

I need to get from the following sample table all rows that match exactly 5 minutes ago from the moment the query was executed.

A query will be scheduled every 5 minutes to get all rows created in this time range.

CREATE TABLE mytable ( date timestamp without time zone NOT NULL, id numeric(8) ) 

I tried with the interval option, but since my table has a column defined as timestamp without time zone , I do not get the right information that I need.

+7
sql postgresql
source share
1 answer

I don't know why INTERVAL not working:

 SELECT * FROM mytable WHERE "date" >= NOW() - INTERVAL '5 minutes'; 
+18
source share

All Articles