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

后端 未结 1 849
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 16:56

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         


        
相关标签:
1条回答
  • 2021-01-27 17:24

    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.

    0 讨论(0)
提交回复
热议问题