then you are lucky that mysql is such a forgiving, lenient database
dates are not strings -- please do not use string functions on them, for two reasons
first, if you do use a string function (like LEFT), you force an implicit conversion of the column value from datetime to string
this leaves open the possibility that the conversion to string does not meet the format that you're expecting, and your code will fail
but second, and far more important, when you apply a function to a column value like that, the database has no choice but to do a table scan, which is very inefficient, even if that column has an index on it for optimization
the "best practice" for what you're trying to do is an
open-ended range test --
Code:
WHERE `date` >= '2012-08-13'
AND `date` < '2012-08-14'
please let me know if you don't understand what that does
Bookmarks