MySQL select records 1 hour ago or fresher on datetime column
14,296
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.
Author by
Admin
Updated on June 24, 2022Comments
-
Admin almost 2 years
Hi I need help with a database MySQL query.
What where clause can I use to select records that are one hour ago or fresher using a
DATETIME
timestamp? -
KilZone almost 13 yearsThe query is good, but he wants '1 hour or younger', that would be
WHERE field >= DATE_SUB...
, wouldn't it? -
Monty almost 10 yearsThis returns other dates as well within the "1 Hour" not just now.