MySql datetime format change

239 Views Asked by At

I have stored date in string format like 'Thu, 24 Dec 2020 07:54:35 GMT'.

Can someone please suggest how to convert this string into YYYY-MM-DD format using MySQL query.

Tried this function :

 str_to_date(dateTime, '%a %d %b %Y %T %x')
    
    DATE_FORMAT(dateTime, '%Y-%m-%d)
    
   DATE(dateTime)
1

There are 1 best solutions below

0
On BEST ANSWER

You can just ignore stuff that comes at the end (assuming you're happy to store the time for the given time zone)...

E.g.

select str_to_date('Thu, 24 Dec 2020 07:54:35 GMT', '%a, %e %b %Y %T') dt;