Your STR_TO_DATE()
format string is invalid. The hours in your sample data use the 24-hour clock (%H
or %k
), not the 12-hour clock (%h
). You can see all possible date format specifiers here.
Will
%d-%b-%y %h:%i:%s
change into
%d-%b-%y %H:%i:%s ^^
Your statement might look like this
LOAD DATA INFILE '/path/to/temp_test.csv' IGNORE INTO TABLE temp_test FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' -- or '\n' IGNORE 1 LINES (@c1, c2) SET c1 = STR_TO_DATE(@c1,'%d-%b-%y %H:%i:%s');
After loading using your sample data
mysql> select * from temp_test; +---------------------+------+ | c1 | c2 | +---------------------+------+ | 2012-06-07 22:50:19 | abc | | 2013-06-07 22:50:19 | bcd | +---------------------+------+ 2 rows in set (0.00 sec)