Here is another alternative. Assuming you have an indexed field of type DATE or DATETIME , this should use an index, since formatted dates will be converted to a type before using the index. Then you should see a range query, not an index query when looking at EXPLAIN .
SELECT * FROM table WHERE date_created >= DATE_FORMAT( CURRENT_DATE - INTERVAL 1 MONTH, '%Y/%m/01' ) AND date_created < DATE_FORMAT( CURRENT_DATE, '%Y/%m/01' )
martin clayton Jan 19 '10 at 0:48 2010-01-19 00:48
source share