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.

Share:
14,296
Admin
Author by

Admin

Updated on June 24, 2022

Comments

  • Admin
    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
    KilZone almost 13 years
    The query is good, but he wants '1 hour or younger', that would be WHERE field >= DATE_SUB..., wouldn't it?
  • Monty
    Monty almost 10 years
    This returns other dates as well within the "1 Hour" not just now.