David Perron wrote:

Are you assuming that all months have 30 days?  You can use the same syntax
with INTERVAL 1 MONTH

True.

I would also format the date comparison to use the same precision that the
DATE_ADD function outputs.

Why would you do that? The date column contains a DATE. CURDATE() returns a DATE. DATE_ADD() returns a DATE. Comparing DATEs is straightforward. DATE_FORMAT returns a string, however, so your query compares a DATE to a string. At best, the difference is optimized away. At worst, an extra conversion takes place. Formatting is for presentation, not comparison.


So,

DATE_ADD(table.date, INTERVAL 1 MONTH) <= DATE_FORMAT(CURDATE(), '%Y-%m-%d')

I might be off on the 1 MONTH part, but I think it's the right track.

Again, compare columns to (functions of) constants. Do not run the column through a function, if at all possible. Thus, this should be


  table.date <= CURDATE() - INTERVAL 1 MONTH

Michael

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to