问题
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