-2

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

Naresh Kumar P
  • 4,127
  • 2
  • 16
  • 33
  • 4
    Possible duplicate of [mySQL convert varchar to date](http://stackoverflow.com/questions/4706289/mysql-convert-varchar-to-date) – RamenChef Sep 16 '16 at 12:42

1 Answers1

0

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' );
Naresh Kumar P
  • 4,127
  • 2
  • 16
  • 33
  • thank you for your help. And it work like this:UPDATE `C` SET `A` = str_to_date(`A`, '%d/%m/%Y'); – Dumitru Dumitrel Sep 16 '16 at 13:43
  • @DumitruDumitrel. I have given you with the procedure of how to do both by renaming the filed to. But you have done it so. – Naresh Kumar P Sep 16 '16 at 16:03
  • @DumitruDumitrel. If you find it useful you shall have marked as correct one or you shall have updated the answer right :) But to a sad thing you have not done any of these bro. :) We are here to help you at any cause but try to do the needful – Naresh Kumar P Sep 16 '16 at 16:04