tags:

views:

48

answers:

2

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
judging by the tags i think it's mysql
arthurprs
+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
+1: You beat me by 23 seconds
OMG Ponies