I have been banging my head against a wall trying to import datetime values from a .csv file.
Here's the import statement.
LOAD DATA LOCAL INFILE 'myData.csv'
INTO TABLE equity_last_import
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(equity,last,@last_date)
SET last_date = STR_TO_DATE( @last_date, '%Y-%m-%d %H:%i:%s')
Here's a sample of the data:
4108,48.74,"2013-09-16 16:15:04" 4249,8.1,"2013-09-16 16:15:04" 4197,3.81,"2013-09-16 17:20:00" 4139,26.81,"2013-09-16 16:15:04" 4218,24.83,"2013-09-16 17:20:00" 4260,79.72,"2013-09-16 16:15:04" 4270,450.12,"2013-09-16 17:20:00" 4242,30.38,"2013-09-16 16:15:04" 4193,1.42,"2013-09-16 16:15:04" 4134,3.77,"2013-09-16 16:15:04"
I am able to import date values using STR_TO_DATE() but I not able to get datetime values to import. I have tried several different date formats other than '%Y-%m-%d %H:%i:%s' and I always get a null datetime [0000-00-00 00:00:00]. I have also tried not using STR_TO_DATE(), since the string is in the default MySQL datetime format.
Any help will be appreciated.