hi guys, really having trouble writing a query.. i've been at it for hours so i thought it might be time to enlist some pro help! I'm trying to select records which are 5 minutes either side of the current time, 3 days ago example, if today's date/time is 2011-06-04 21:15:00, find records between the below dates: 2011-06-01 21:10:00 2011-06-01 21:20:00 thanks very much!
How about trying following? SELECT column_names FROM table_name WHERE date_column BETWEEN FROM_UNIXTIME(UNIX_TIMESTAMP() - 259500) AND FROM_UNIXTIME(UNIX_TIMESTAMP() - 258900); Code (markup): If the queries are gonna be frequent and database is gonna be large, i suggest to keep column as bigint and store date as unix timestamp in it. The searching will be faster that way.