Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a C# webservice(server) and C# windows form(client). My webservice method accepts a dataset object as parameter. The dataset has 2-3 datatables, and in the tables there are datetime columns.

The client is installed in different locations, when the dataset is sent from a client the datetime columns are modified by adding/subtracting the datetime offset values, because of this the webserver is receiving the wrong dates.

I am not in a position to change anything on the client, how can I handle the issue on the server side (in web service).

All I want is that the date fields should be transferred exactly as entered at client(like string data type).

I am using access database as backend for windows forms client. When exporting the data from client, the client creates a dataset(2-3 tables) and passes the dataset to webservice method. I debugged the client and I think it is during the serialization, the datetime offset is added to datetime columns. I want to remove offset during de-serialization.

example: if at client the date is 01/01/2011, the server is receiveing it as 31/12/2010.

Thanks in advance
Posted
Comments
Motamas 12-Mar-13 10:55am    
I am not fully understand but I guess the problem is the different time zone settings. Maybe the DateTime function called ToLocalTime could help? The DataColumn type is DateTime?

(note: I think DataSet is too heavy for webservice interaction, it works but too complex. This is not relevant for the answer just a note.)

1 solution

There are 2 approaches

1. UseUTC-DateTime and always convert to localtimezone at the client
2. Convert the client/server specific timezones using the TimeZoneInfo class

The TimeZone class recognizes local time zone, and can convert times between Coordinated Universal Time (UTC) and local time. A TimeZoneInfo object can represent any time zone, and methods of the TimeZoneInfo class can be used to convert the time in one time zone to the corresponding time in any other time zone. The members of the TimeZoneInfo class support the following operations:

Retrieving a time zone that is already defined by the operating system.
Enumerating the time zones that are available on a system.
Converting times between different time zones.
Creating a new time zone that is not already defined by the operating system.
Serializing a time zone for later retrieval.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900