At 1:47 AM -0800 2000-01-06, Bill Gerrard wrote:
>Hi Paul,
>
>My code sample was written to 3.21.x, which didn't include DATE_SUB. If it
>did, I would have used it there... :(
>
>> 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)
I guess then I would use:
WHERE date >= FROM_DAYS(TO_DAYS(CURDATE()) - 7)
The right hand side can still be optimized as a constant and an
index on date can be used, if one exists.
--
Paul DuBois, paul@stripped