问题
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
回答1:
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
回答2:
The machines may need to have their locale settings changed, and not just the timezone settings. I believe they are separate.
回答3:
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
来源:https://stackoverflow.com/questions/4441100/oledb-datetime-issue-asp-net-c-sharp