Geeks With Blogs
Nigel Parker BizTalk 2004 Developer - Auckland, New Zealand,

I was working with a schema this week that had an <xs:date> type in it. I loaded the schema into BizTalk and set the <xs:date> field to be a distinguished property. When accessing the property I noticed that it had converted the xs:date property to a System.DateTime type.

What had happened was that the date had been converted to UTC format behind the scenes; From the bizTalk docs (If the datetime format does not specify time zone or UTC format, the time is assumed to be local and is converted to UTC based on the current time zone.)

e.g. Say the date that was passed in was ‘2004-10-26’ when I accessed it by the distinguished property it’s value was ‘2004-10-25 11:00:00’ (UTC-13) - New Zealand timezone… therefore “distinguishedDeliveryDate.ToString("dd/MM/yyyy",System.Globalization.CultureInfo.InvariantCulture)” returned 25/10/2004 instead of what I was looking for 26/10/2004.

The solution:
Convert the datetime back from UTC datetime to local datetime using something similar to:

distinguishedDeliveryDate  = distinguishedDeliveryDate.Add(TimeZone.CurrentTimeZone.GetUtcOffset(distinguishedDeliveryDate));

VOLA

Posted on Thursday, October 28, 2004 10:48 PM BizTalk Tips & Tricks | Back to top


Comments on this post: Interesting "gotcha" when working with xs:date fields in BizTalk 2004

# re: Interesting "gotcha" when working with xs:date fields in BizTalk 2004
Requesting Gravatar...
Hey,

I think that if you look into it a bit more you find that this is a general .NET problem when serializing DateTimes into Xml.

But a good solution to the problem
Left by Barry Latimer on Nov 07, 2004 11:13 PM

Your comment:
 (will show your gravatar)


Copyright © Nigel Parker | Powered by: GeeksWithBlogs.net