Choose a timestamp older than

How can I select items older than 12 hours from the database ?! I use the timestamp column to store the time, but I don’t think I need a year, month, day, only a clock. I have something like this, but it doesn’t work (the error does not return all the data from the table)

$sql = "SELECT *FROM Y WHERE X and time > now() - INTERVAL 12 HOUR";

Type: Timestamp

You're right Salman A. Thanks for

+5
source share
1 answer

Try the following:

SELECT * FROM Y WHERE X and time < (NOW() - INTERVAL 12 HOUR)

you need <instead >, because you want to select entries older than 12 hours

+7
source

All Articles