
Originally Posted by
r937
"comparing dates to datetimes also changed" -- i would like to see proof of this
as far as i know, and i have tested it often, what i posted works perfectly for both dates and datetimes
This was happening very long time ago so I don't think I can prove anything - the difference might have been between 5.0 and 4.1 or even 4.0, one was on a Unix hosting the other on Windows. Things have changed so for any practical purposes I think what you say is true nowadays.

Originally Posted by
r937
also, your approach using BETWEEN has two inconvenient drawbacks
They are not so inconvenient 

Originally Posted by
r937
-- first, you will always have to do a leap year calculation (for the last day of the month),
MySQL will allow me to do this:
Code:
WHERE action_date BETWEEN '2012-02-01 00:00:00' AND '2012-02-31 23:59:59'

Originally Posted by
r937
and second, you might miss some rows between 23:59:59 and midnight (assuming mysql supports subseconds)
MySQL 5.6.4 seems to support microseconds - if I have the very unlikely need for them I might do this:
Code:
WHERE action_date BETWEEN '2012-01-01 00:00:00' AND '2012-01-31 23:59:59.999999'
But I'm giving you credit for better elegance of your way of comparing
Bookmarks