Andrey Tsarev
Andrey Tsarev

Reputation: 779

How to get rows older than 30 min

I have a MySQL table with column time which remembers the time of the row.

So my question is how to get rows where time is older than 30 minutes ?

I have red some threads but I get errors. I have tried these, but none of them works...

SELECT * from temp WHERE to_timestamp(insert_date) < NOW() - INTERVAL '30 minutes' 

SELECT * FROM temp WHERE insert_date < NOW() - INTERVAL '30 minutes';

Upvotes: 1

Views: 7461

Answers (2)

artur99
artur99

Reputation: 818

SELECT * FROM temp WHERE `timestamp` < (NOW() - INTERVAL 30 MINUTE);

You could take it from just replacing Delete with Select :)

MySQL Delete Records Older Than X Minutes?

MySQL: Delete all rows older than 10 minutes

Upvotes: 9

M.Ali
M.Ali

Reputation: 69524

SELECT * FROM temp 
WHERE insert_date < date_sub(now(), interval 30 minute) 

Upvotes: 3

Related Questions