At 10:34 AM -0800 2000-01-05, Bill Gerrard wrote:
> > How do I tell MySQL to retrieve all records last then one week old?
>
>We used something like...
>
>SELECT * FROM table
>WHERE TO_DAYS(date) >= (TO_DAYS(CURDATE())-7)
>ORDER BY date;
If you use the following, MySQL can take advantage of any index
on the date column. The expression above is logically equivalent,
but requires that TO_DAYS(date) be evaluated for each row in the
table.
WHERE date >= DATE_SUB(CURDATE(),INTERVAL 7 DAY)
--
Paul DuBois, paul@stripped