csv - how to enter data into mysql table with wrong date format -
i have csv file lots of different columns, 1 column having date in dd-mm-yyyy format . mysql's default format yyyy-mm-dd . planning load csv file directly mysql table , may cause problem. should . ps- not planning run code other language on file , appreciate solutions include use of mysql itself.
if able perform multiple steps first import csv intermediate table has same properties real data table, except date columns.
then can insert real table , format date-string while selecting
insert realtable (/* ... */) select /*.... */, str_to_date('01-5-2013','%d-%m-%y') intermediatetable;
when ready truncate table, done. should done in transaction can rollback if goes wrong.
edit: seems better way: https://stackoverflow.com/a/4963561/3595565 should able format date while importing using variable
Comments
Post a Comment