Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL select records 1 hour ago or fresher on datetime column

What where clause can I use to select records that are one hour ago or fresher using a DATETIME timestamp?

like image 718
Marty Avatar asked Jun 08 '11 08:06

Marty


1 Answers

Something like this? I assume an DATETIME timestamp is an DATETIME field.

SELECT * FROM table WHERE datetimefield >= DATE_SUB(NOW(), INTERVAL 1 HOUR)

For more information check MySQL's date/time functions.

like image 199
Wesley van Opdorp Avatar answered Oct 16 '22 13:10

Wesley van Opdorp