I have to import a csv into a mysql database with a funny date format so I decided to use STR_TO_Date() to convert it, however it pulls an error on the second conversion when I try to put multiple conversions for the dates.
LOAD DATA LOCAL INFILE 'e:/the.csv'
INTO TABLE data
FIELDS OPTIONALLY ENCLOSED BY '"' TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 ROWS
(ID, UID, Barcode, Name, @Start, @End, Seconds)
SET Start = STR_TO_DATE(@Start, '%d/%c/%Y %H:%i')
SET End = STR_TO_DATE(@End, '%d/%c/%Y %H:%i')
My database looks along the lines of:
ID UID Barcode Name Start End Seconds
29 12345 BBB6168 namehere 09/12/2014 18:00 09/12/2014 18:09 538
30 12345 AAA6168 namehere 10/12/2014 11:01 10/12/2014 11:02 4
31 AAAAA ABC6084 namehere 10/12/2014 11:34 10/12/2014 11:34 5
How can I fix this?
varchar) and convert it to the desired format after you've imported it