>What is the most efficient way to select records based on a field called NOW
which contains a date or a datetimestamp
I use:
SELECT * FROM `TBL` WHERE
DATE_ADD( `TBL`.`NOW` , INTERVAL 3 MONTH ) > CURDATE( );
Is this the best way?
I think something like:
SELECT * FROM `TBL` WHERE
`TBL`.`NOW` > DATE_SUB(CURDATE(), INTERVAL 3 MONTH);
might be faster if the query optimizer doesn't deal with it. With
the first query, you evaluate DATE_ADD() once for each row in the
table. With the second, you evaluate DATE_SUB() once. In general,
comparing a table field against a computable run-time constant is
more likely to use an index than comparing some function of a table
field against something. Or, they might be equivalent in speed.
Gordon L. Burditt