I'm doing my first CSV import into MySQL and noticed that the date in the CSV has the format 31-Jan-2011
. How can I convert this to 2011-01-31
so I can place it in the DATE datatype? The first thing which came to mind is let PHP do the conversion then insert it into a 2nd table but I'm guessing that's...not right.
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
If the file isn't too big, load the CSV into Excel and use the formatting commands there to change the date representation.
You can replace format during importing data from the CSV file, for example -
It will format the string like '31-Jan-2011' to a correct DATETIME data type.
More information here - LOAD DATA INFILE Syntax.