We have a web service that gets data in xml format. In that Xml data, we
parse few date fields that are in this format
<data datefield="12/26/2008" timefield="16:33:45" ...>
we parse it into a DateTime field using DateTime.Parse( datefield ).Add(
TimeSpan.Parse( timefield ).
For some reason, on 26th of this month from 4pm to 5pm, for certain web
service calls, the date field was calculated incorrectly. Like a 12/26/2008
16:00:00 would be parsed as 12/27/2008 4:00:00. For some reason, the dates
were added by 12 hours automatically.
We have this code in production for a long..never found such an issue. It
happend only during the time mentioned above..and never before..and never
after. More
over, we have 2 servers in production, and this error happend on one of the
servers only. The other server processed the calls just fine.
We have same code deployed on both servers, and both these servers have same
configuration ( OS, patches and all ). Both these servers are identical.
Can you please tell me if you have faced such an issue before. I am not even
sure if its related to web service problem, or server problem, or database
problem.
The code was written in c#. Please let me know if you need more information.
thank you for your help..
Fredo - 01 Mar 2008 00:34 GMT
Is it possible someone just changed the time on one of the servers or in
some other way the time got messed up on that server temporarily? Perhaps
someone changed the region/culture settings.
If you have a time and date format in a known format, you should really pass
in a format string for the Parse, or, at the very least, force the culture.
> We have a web service that gets data in xml format. In that Xml data, we
> parse few date fields that are in this format
[quoted text clipped - 27 lines]
> information.
> thank you for your help..
Alvin Bruney [ASP.NET MVP] - 01 Mar 2008 01:05 GMT
I've heard a roughly similar story. Can you determine if the caller is in a
different time zone when the call fails? There's a chance that it may be the
issue I've dealt with, basically a date deserialization issue.

Signature
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------
> We have a web service that gets data in xml format. In that Xml data, we
> parse few date fields that are in this format
[quoted text clipped - 27 lines]
> information.
> thank you for your help..
Claes Bergefall - 03 Mar 2008 10:48 GMT
I've seen it happen when the timezone or culture settings are wrong.
Don't use DateTime.Parse if you know exactly what format you're expecting.
Use DateTime.ParseExact instead and pass in the format string (and an
invariant culture). Skip TimeSpan.Parse since you can't control the format
and instead combine the two strings into one before parsing. Try this:
string datetime = datefield + " " + timefield;
string format = @"MM\/dd\/yyyy HH\:mm\:ss";
IFormatProvider provider =
System.Globalization.DateTimeFormatInfo.InvariantInfo;
DateTime dt = DateTime.ParseExact(datetime, format, provider);
This assumes that single digit months and days have a leading zero. If
that's not the case try the following format string instead:
string format = @"M\/d\/yyyy HH\:mm\:ss";
/claes
> We have a web service that gets data in xml format. In that Xml data, we
> parse few date fields that are in this format
[quoted text clipped - 27 lines]
> information.
> thank you for your help..