phpmyadmin import csv with difficult on date format

喜欢而已 提交于 2020-02-25 05:48:08

问题


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!



来源:https://stackoverflow.com/questions/17483436/phpmyadmin-import-csv-with-difficult-on-date-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!