Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time bracket for SYSDATE

I need to select rows where timestamp is between now and 5 minutes in the past. How do I do it? Something like that:

select * from tableName where timestamp between sysdate and up to -5 min

The simpler - the better.

like image 955
Prostak Avatar asked Mar 23 '26 20:03

Prostak


1 Answers

select *
  from tableName
 where timestamp between sysdate and sysdate - interval '5' minute

or old style:

select *
  from tableName
 where timestamp between sysdate and sysdate - 5 * 60 / 86400
like image 169
zerkms Avatar answered Mar 25 '26 11:03

zerkms



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!