[ACCEPTED]-MySQL load dates in mm/dd/yyyy format-csv

Accepted answer
Score: 10

You can load the date strings into user-defined 2 variables, and then use STR_TO_DATE(@date, '%m/%d/%Y') to convert them 1 to MySQL dates.

Try this:

load data infile  '/Users/pfarrell/sandbox/waybase/folklore/Titles_1976.csv'
into table fix76
fields terminated by ','
enclosed by '"'
ignore 1 lines
(  patentId,  USPatentNum,  title,  @grantDate,  @filedDate)
set grantDate = STR_TO_DATE(@grantDate, '%m/%d/%Y'),
filedDate = STR_TO_DATE(@filedDate, '%m/%d/%Y')

More Related questions