Reputation: 2465
I'm trying to import (through phpMyadmin import option) a csv file to mysql table. The CSV file has a column date with the format mm/dd/yyyy
(10/21/2009) and the column in mysql table has the date format yyyy-mm-dd
. I've tried to change formats in csv but after importing to mysql the date column shows 0000-00-00
or some other wrong dates. Which is the correct date format to be stored in the csv file so that it shows the correct date after importing?
Thanks.
Upvotes: 0
Views: 174
Reputation: 73031
varchar
)Date
)STR_TO_DATE()
to convert.In your case:
UPDATE your_table SET new_date_col = STR_TO_DATE(old_date_col, '%m/%d/%Y')
Adjust the original format to your needs.
Upvotes: 2