Yachee
Yachee

Reputation: 1

mysql how to compare date in the format dd-mon-yy

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

Upvotes: 0

Views: 1174

Answers (1)

Alex Wittig
Alex Wittig

Reputation: 2900

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.

Upvotes: 1

Related Questions