From: "Ashley M. Kirchner" <[EMAIL PROTECTED]> > >RD> SELECT whatever FROM table WHERE date_column_name BETWEEN '2004-01-09 > >RD> 00:00:00' AND '2004-01-04 23:59:59' > > > >Actually sorry, inverse the seconds (put the 00:00:00 onto the lower > >date, the 4th) so it encompasses the whole period. You might actually > >be able to not even include the seconds, try it and see what happens. > > > > > Assume I don't know what those dates are. I need to search based on > whatever the current date is, and search between 2 and 7 days back. The > dates in my previous post were simply an example.
Should have said that in the first place. :) SELECT * FROM table WHERE TO_DAYS(datetimefield) BETWEEN TO_DAYS(CURDATE() - INTERVAL 2 DAY) AND TO_DAYS(CURDATE()) The "2" in the query can be a PHP variable ranging from 2 - 7, if you want. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php