MySQL str_to_date produces NULL despite valid formatting

后端 未结 1 1859
失恋的感觉
失恋的感觉 2021-01-24 02:35

I\'m trying to use the str_to_date function from mysql to convert a TEXT field to a date. Now running:

mysql> select Date from sampleData limit 2;
+----------         


        
相关标签:
1条回答
  • 2021-01-24 02:56

    It looks like you have those doublequotes in there also. When you try to convert it with the doublequotes, you get null.

    Try doing:

    select str_to_date(REPLACE(Date,'"',''), '%d-%m-%Y') 
    from tab1 sampleData 2;
    

    sqlfiddle demo

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