I need to select all data in table created not less than 24 hours ago. Anyone know how to do this?
A:
Depends on your database. Look up the date math functions e.g. datediff and date_sub in your help files.
Tim
2010-09-27 02:28:11
judging by the tags i think it's mysql
arthurprs
2010-09-27 02:29:36
+6
A:
Assuming your table has a DATETIME field, in this example called date_field
SELECT * FROM tablename WHERE date_field <= SUBDATE( CURRENT_DATE, INTERVAL 24 HOUR)
OR
SELECT * FROM tablename WHERE date_field > NOW() - interval 1 day
yc
2010-09-27 02:30:19