Select * in the table where the date and time is 24 hours ago

I need to select all the data in the table created at least 24 hours ago. Does anyone know how to do this?

+5
source share
2 answers

Assuming your table has a DATETIME field, in this example the name is date_field

SELECT * FROM tablename WHERE date_field >= SUBDATE( NOW(), INTERVAL 24 HOUR)

OR

SELECT * FROM tablename WHERE date_field > NOW() - interval 1 day
+15
source

Depends on your database. Look at the math functions of a date, for example. dateiff and date_sub in the help files.

0
source

All Articles