Reputation: 1543
I'm following documentation from here: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
This one gave me result:
WHERE (DATE_FORMAT( date_time, '%Y %m' ) BETWEEN '2014 03' AND '2014 06')
but this one does not:
WHERE (DATE_FORMAT( date_time, '%Y %M' ) BETWEEN '2014 March' AND '2014 June')
I want to use date like this: April 2014
What did I do wrong? Thanks in advance for any input.
Upvotes: 0
Views: 333
Reputation: 829
You cannot compare strings. The comparisons you are looking at are alphabetical, so nothing matches because "March" > "June".
The comparison of two stings. M
is greater than J
in the alphabet therefore 2014 March is GREATER than 2014 June.
Don't ever try to use strings for comparison factors.
Upvotes: 1