Home > Blockchain >  MySQL Date Format From Fri Jan 10 00:00:00 UTC 1992 to YYYY-MM-DD
MySQL Date Format From Fri Jan 10 00:00:00 UTC 1992 to YYYY-MM-DD

Time:11-24

I have a data "Fri Jan 10 00:00:00 UTC 1992" And I want to convert it to 1992-10-01.

I know how to do it with Javascript, but I have no idea how to do it with MySQL

I tried : DATE_FORMAT(column, '%d/%m/%Y')

But it's return null

CodePudding user response:

select date_format(str_to_date("Fri Jan 10 00:00:00 UTC 1992","%a %b %d %H:%i:%s UTC %Y"),"%Y-%m-%d");

First you need str_to_date, using "%a %b %d %H:%i:%s UTC %Y" to get a date, after that you can format the date using date_format in the desired format.

These specifiers shown in the following table may be used in the format string.

  • Related