Well, thanks everybody for their help. Looks like it was an un-escaped character in the date formatting: '%%d/%%m/%%Y %%H:%%i' is what I needed. Since this is being run from a batch file, I didn't take that into account.
I've got a batch file that runs an SQL command and I thought I understood what was required, but can't seem to make it all come together. When I run the code below, I get everything to import properly, but either my STR_TO_DATE formatting must be off or the way I'm targeting the second column must be off, as I just get "(NULL)" or all zeros in my DATETIME column when I run the script below.
Here's a screenshot of what I'm seeing from the command prompt window. The suspicious part is highlighted in green: https://i.stack.imgur.com/3mlsi.png
Any ideas?
CREATE TABLE `serials` (
`Serial` INT(10) UNSIGNED NULL DEFAULT '0',
`Stamp` DATETIME NULL DEFAULT NULL,
`Data1` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data2` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data3` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data4` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data5` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data6` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data7` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
`Data8` MEDIUMINT(8) UNSIGNED NULL DEFAULT '0',
INDEX `StampINX` (`Stamp`),
INDEX `SerialINX` (`Serial`)
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM;
echo on
setlocal enabledelayedexpansion
FOR %%f IN ("*.csv") DO (
set old=%%~dpnxf
set new=!old:\=\\!
mysql -e "LOAD DATA local INFILE '"!new!"' IGNORE into table test.serials COLUMNS TERMINATED BY ','
(Serial,@Stamp,Data1,Data2,Data3,Data4,Data5,Data6,Data7,Data8) SET
Stamp=STR_TO_DATE(@Stamp,'%d/%m/%Y %H:%i')" -u root -ppassword
echo %%~nxf DONE
)
and below is a sample of the file I'm accessing with the LOAD DATA INFILE function
Serial,Stamp,Data1,Data2,Data3,Data4,Data5,Data6,Data7,Data8
50183,01/01/2012 00:15,0,77,73,84,0,0,3,62
50183,01/01/2012 00:30,0,100,45,77,0,0,3,67
50183,01/01/2012 00:45,0,96,62,73,0,0,2,61
50183,01/01/2012 01:00,0,81,79,85,0,0,3,56
Your string format for
STR_TO_DATE
should be:You were missing the slashes.