Quantcast
Channel: import CSV to MySQL and convert date - Stack Overflow
Browsing index pages (3 articles)

import CSV to MySQL and convert date

I know this question has been asked before but for some reason I am having zero luck still. I am trying to import a CSV file and convert the date field to proper mysql format (YYYY-MM-DD). I should...

View Article


Answer by Patrick Moore for import CSV to MySQL and convert date

If you're doing this only once, and the table is empty to start, you could run the import but first alter your table so the date column is of type VARCHAR. Then run UPDATE table SET date = str_to_date(...

View Article


Answer by Jacob for import CSV to MySQL and convert date

This might be correct-LOAD DATA LOCAL INFILE '/Users/Path/To/CSV/file.csv'INTO TABLE tbl1 FIELDS TERMINATED BY ','LINES TERMINATED BY '\n'(@date,INSTRUCTIONS)SET date = STR_TO_DATE(@date,'%Y/%m/%d);Why...

View Article
Browsing index pages (3 articles)


Latest Images