sdc248
asked on
JExcel date format
Hi:
I am using JExcel to read data from an excel file published on the web and put it in our internal database. One of the columns in the file is date of format (mm/dd/2003). I do something like:
String theloaddate = null;
theloaddate = cell[0].getContents();
then I write "theloaddate" to a temporary csv file and bulk insert the file to a database table.
I got a SQLException as below:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 289, column 1 (LoadDate).
I checked the temporary file and found the format of "theloaddate" column somehow got changed to dd/mm/yyyy which is fine, but I just can't see what's the problem with row 289. It looks exactly the same with any other rows.
Please help. Thanks.
I am using JExcel to read data from an excel file published on the web and put it in our internal database. One of the columns in the file is date of format (mm/dd/2003). I do something like:
String theloaddate = null;
theloaddate = cell[0].getContents();
then I write "theloaddate" to a temporary csv file and bulk insert the file to a database table.
I got a SQLException as below:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Bulk load data conversion error (type mismatch or invalid character for the specified codepage) for row 289, column 1 (LoadDate).
I checked the temporary file and found the format of "theloaddate" column somehow got changed to dd/mm/yyyy which is fine, but I just can't see what's the problem with row 289. It looks exactly the same with any other rows.
Please help. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
In my case it's:
DateFormat dfSource = new SimpleDateFormat("dd/MM/yy yy");
DateFormat dfTarget = new SimpleDateFormat("MM/dd/yy yy");
but I got your point. And it's working. Thanks a lot.
DateFormat dfSource = new SimpleDateFormat("dd/MM/yy
DateFormat dfTarget = new SimpleDateFormat("MM/dd/yy
but I got your point. And it's working. Thanks a lot.
:-)
ASKER
That cell is 3/13/2003 (mm/dd/yyyy) but got changed to 13/03/2003 and SQL Server simply doesn't accept month 13. What should I do now?