.comment-link {margin-left:.6em;}

Ben Cops

Monday, July 25, 2005

Interesting "gotcha" when working with xs:date fields in BizTalk 2004

Interesting "gotcha" when working with xs:date fields in BizTalk 2004

Done and done - thank god for google again!

Edit: Posting the text of the blog in case it disappears....

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));

4 Comments:

  • Heya neato
    Needed to find out if you are JZ that posted here
    on my blog? http://www.dogsofpoker.net/
    He left this blog as his site?
    Did you post on my blog?

    By Anonymous Anonymous, at 2:00 pm  

  • Hi people
    I do not know what to give for Christmas of the to friends, advise something ....

    By Anonymous Anonymous, at 3:29 pm  

  • Hello. Good day
    Who listens to what music?
    I Love songs Justin Timberlake and Paris Hilton

    By Anonymous Anonymous, at 11:41 am  

  • I have been interested in this theme for a long time and it was insulting for me that during development of technologies, I still search for the information offline. With the advent of your site I have plunged with all my soul into Internet.
    - bencops.blogspot.com x
    spaghetti alla carbonara

    By Anonymous Anonymous, at 7:28 am  

Post a Comment

<< Home