Link to home
Start Free TrialLog in
Avatar of sdc248
sdc248Flag for United States of America

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.
Avatar of sdc248
sdc248
Flag of United States of America image

ASKER

ok, I see what's wrong with row 289 now.
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?
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sdc248

ASKER

In my case it's:
DateFormat dfSource = new SimpleDateFormat("dd/MM/yyyy");
DateFormat dfTarget = new SimpleDateFormat("MM/dd/yyyy");

but I got your point. And it's working. Thanks a lot.

:-)