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

我是研究僧i 提交于 2021-02-17 05:43:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!