i have a csv file with one of the column as format: 20131231 (eg. 2013-12-31)
i've a mysql table with field column 'date' with format int(10).
i want to use phpmyadmin to import the csv file so that the mysql table can accurately capture the date. Pls advise how to do so, thanks.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I would first create a temporary column to hold the date string, then import the csv as it is, then use the following SQL statement:
UPDATE tablename SET actual_date_column = STR_TO_DATE(temp_date_column, '%Y/%m/%d');
More info on STR_TO_DATE()
Hope that helps!