DateTime, Web service, Sql server

I

Iwan Petrow

Hi,
I have Win application -> Web service -> Sql Server. The user input
date and time in format dd/MM/yy hh:mm. I convert it to datetime and
send it to a web service which save it to the db. But the datetime is
changed according the timezone of the server and the client machine (I
think).

What can I do that the date to stay the same (I want to send datetime
type and I don't want to change windows setting of the server and the
client machine)?

Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

Iwan,

Which layer is it being translated in? Is the proxy translating it when
it is sent to the web server? Or is the SQL Server translating it?

Either way, before you send it, you might want to convert it to GMT, by
making a call to the ToUniversalTime method on the datetime before you send
it to the web service.

Hope this helps.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

That's weird, I have never hear of that, how the client or the web service
knows that the opposite is in a different timezone?

I would bet you have another problem somewhere else.

cheers,
 
I

Iwan Petrow

Hi,

When I set time zone of the serever machine +2 and timezone of the
client machine +1 (windows os settings) I have this problem. When they
are equal (+2) there is no ptroblem.
 
J

Jon Skeet [C# MVP]

That's weird, I have never hear of that, how the client or the web service
knows that the opposite is in a different timezone?
I would bet you have another problem somewhere else.

I've seen this problem with Java webservices talking to .NET ones - the
..NET SOAP deserializer does some time zone alterations under the hood
so that even if you send a UTC date/time from Java, you end up with a
local date/time in .NET. It's all very annoying. I gather it's fixed to
some extent in .NET 2.0, but the problem basically stems from the
DateTime type not having any timezone information.

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top