Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL: Obtain rows from table from 5 minutes ago

Tags:

sql

postgresql

I need to obtain from the following example table all the rows that match the exactly 5 minutes ago since the query is run.

The query will be scheduled to run every 5 minutes to get all the rows that were created in that range of time.

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

I've tried with the interval option but because my table has the column defined as timestamp without time zone I'm not getting the proper info that I need.

like image 547
Luke Avatar asked Mar 13 '14 20:03

Luke


1 Answers

Not sure why INTERVAL is not working:

SELECT * FROM mytable WHERE "date" >= NOW() - INTERVAL '5 minutes'; 
like image 169
Cody Caughlan Avatar answered Sep 23 '22 19:09

Cody Caughlan