问题
How do I compare date in the format dd-mon-yy
? For example: 10-NOV-14 > 07-OCT-13.
select expiration_date from grocery where expiration_date < 14-oct-13
回答1:
Use STR_TO_DATE:
select expiration_date from grocery
where expiration_date < STR_TO_DATE('14-oct-13', '%d-%b-%y')
expiration_date
will also need to be wrapped in STR_TO_DATE
if it is not already a DATE
format.
来源:https://stackoverflow.com/questions/19366376/mysql-how-to-compare-date-in-the-format-dd-mon-yy