cs0815
cs0815

Reputation: 17388

OLEDB date(time) issue asp.net c#

I have written a little excel helper which works fine. It uses this connection string:

"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=<FILENAME>;Extended Properties=\"Excel 12.0;HDR=Yes;\";";

Unfortunately when I deploy the code, cells, which contains a date string like this: 28/12/2008 are returned as: 12/25/2008 12:00:00 AM rather than 25/12/2008 00:00:00 after using ToString. I adjusted the time zone etc. of the machine (all machines are now UK time zones) but this hasn't changed anything. I am just curious what determines how OLEDB 'behaves'. The aim would be to get 25/12/2008 00:00:00 on both machines.

Thanks!

Christian

Upvotes: 1

Views: 1923

Answers (3)

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65371

You have American datetime settings, either change this or use the numberformat to show it in the format you want, see http://www.mvps.org/dmcritchie/excel/datetime.htm

Upvotes: 1

Neil Knight
Neil Knight

Reputation: 48537

I think that this might be something to do with the Culture being set to en-us. You would need to format the DateTime accordingly.

Standard Date and Time format strings

Upvotes: 2

jocull
jocull

Reputation: 21085

The machines may need to have their locale settings changed, and not just the timezone settings. I believe they are separate.

Upvotes: 1

Related Questions