Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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')

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But it’s return null

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading