Search code examples
mysqlstr-to-date

How to convert a string to date in Mysql ? I try to use str_to_date but I did not succeed


I have a table C

create table C (A varchar(100), B varchar (100));

In columns A and B I have this information:

       A            B
    22/04/2005   01:52:34
    05/12/2005   04:16:02
    07/11/2004   11:24:27
    07/05/2008   06:35:44
    19/02/2007   05:42:00

I try to convert from string to date this columns: A and B in SQL but i do not how i can do this


Solution

  • You can update the existing column to date in mysql using the following code.

    UPDATE `table` set `new_column` = str_to_date( `old_column`, '%m/%d/%Y' );