How to compare a longtext and date value in sql?

一个人想着一个人 提交于 2019-12-02 14:46:12

问题


I have date value stored in format dd.mm.yyyy as longtext. I need to compare this value to CURDATE() within a SELECT statement. (Please, don't ask me why it is saved in longtext.) Is there any way to do it?

This piece of code is not working of course, but it illustrates what I want to do:

...
WHERE longtext_date_value <= CURDATE()
...

回答1:


As Sergey comments: if MySQL, you can simply use STR_TO_DATE:

    ...
WHERE STR_TO_DATE(longtext_date_value,'%d.%m.%Y') <= CURDATE()
    ...


来源:https://stackoverflow.com/questions/9351476/how-to-compare-a-longtext-and-date-value-in-sql

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