STR_TO_DATE from CSV column returns Null

octavemirbeau :

I have a table that contains VARCHAR in (i.e. 2020-01-12) format, that I would like to convert to "January 12th 2020" date format.

How would one go about this?

Gordon Linoff :

You can use date_format() to convert this to a date:

select date_format('2020-01-12', '%d %M')

Although you should be storing the value as a date, the column will be properly converted to a date. I would advise you to change it, say:

alter table t alter column datecol date;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=372581&siteId=1