Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

same tricky date time question

Status
Not open for further replies.

toptomato

Programmer
Jul 22, 2005
62
US
hi guys i am posting this again hoping to better articulate the issue in hopes to find solution to the problem.
here is the senario:
Webservice1 runing on a server in EST Time Zone return a dataset with a DateTime Column in it.
Consumer application running on server1 in PST Time Zone calls Webservice1, get the dataset from the webservice and then bind DataGrid1 to the dataset.
Consumer application running on server2 in EST TimeZone calls Webservice1, get the dataset from the webservice and then binds DataGrid1 to the dataset.
Both Consumer applications are identicall and call the webservice at the same time. On Server1 datagrid's 1st row's DateTime column has value "Wed Dec 7, 6:00PM" while the same value on Server2 is "Wed Dec 7, 9:00PM". Can some one explain this. I tried chaning the time zone on the testbed server hosting consumer application but that didn't change time at all. regardless to what ever time zone i switched to on the testbed server it didn't change the time. Hope i articulated it well this time.
thank guys
 
The DateTime data type is actually stored as a huge integer whose value is a certain time (in milliseconds I think) away from a point in time GMT. When it's read on a client, it translates this value into local time, thus you see a difference.

You'd be better off sending the value as a string back and forth:

Code:
//send to client
string toSend = DateTime.Now.ToString();

//translate at client
DateTime dt = Convert.ToDateTime( toSend );

and vice versa.
 
Toppy-T,

My research shows that MS does not provide the functionality you need.

I did find this: For $199, they have a component that seems to do just what you need. I've never heard of the company and am not affiliated with them in any way.

Andrew
 
ah, i am stuck, i hate to convert the datetime column into string column since the webservice sends the dataset and in order to send datetime as string i would have to convert the whole column into string column. Any other alternative any one. Could localization or cultures in AsP.net can come to rescue me? Any thoughts...
 
You might be able to do something with TimeZone and TimeZone.GetUtcOffset() to run a conversion or even code your own struct with implicit conversions from DateTime to cut down on explicit conversion code, but other than that, I'm not sure what the best way to handle it would be. Most of the googling I just did involves serializing and deserializing to/from a string. :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top