Why does Biztalk Adjust Date?

Home Page Forums BizTalk 2004 – BizTalk 2010 Why does Biztalk Adjust Date?

Viewing 1 reply thread
  • Author
    Posts
    • #13982

      strRequestDateTime = msgPaymentUpdateRequest.RequestDateTime;

      <myMessage RequestDateTime=\”2006-07-07T09:06:09.5156250-06:00\”/>

      The date is obviously 9:06 AM, but in a debug statement, Biztalk shows the variable as 3:06 PM. Wer are mountain time, so it seems to be adding six hours from GMT.

      Should I call a C# static method to handle the date?
      Obviously, I don’t want the date to change.

      I know from the past, that if you do a DateTime.Now() in Biztalk, at least here at this client, the date is adjusted by the six hours. But I don’t understand why accessing an attribute value would be adjusted.

      Thanks,
      Neal Walters

    • #13983

      I just noticed that the date has an extra \”bonus feature\” after the time:

      RequestDateTime=\”2006-07-07T09:06:09.5156250-06:00\”/>

      Note the -06:00 after the hour/min/seconds.

      I haven’t seen this before, but I think it is the cause of the problem.
      Our website serializes a .NET class, and it serializes the date/time to this format.

      In the first post, my variable strRequestDateTime was actually a DateTime. I tried changing variable to a string, and did this:

      strRequestDateTime = System.Convert.ToDateTime(etc)…

      and it still converted it 6 hours ahead.

      Neal

      • #13984

        Here’s my get-around:

        dtTempDateTime = msgPaymentUpdateRequest.RequestDateTime;

        strRequestDateTime =
        System.Convert.ToString(dtTempDateTime.ToLocalTime());

        This really doesn’t make sense to me, but it works.

        I created a C# Console program as follows:

        [code:1:55c4620cde]DateTime myDateTime = DateTime.Now;
        Console.WriteLine(\"DateTime=\" + myDateTime);
        Console.WriteLine(\"ToLocalTime\" + myDateTime.ToLocalTime());
        Console.ReadLine(); [/code:1:55c4620cde]

        It seems odd, but it shows 6 hours previous i.e. 3AM, which is NOT GMT.
        Apparently if you take a non-GMT time and try to convert it to GMT, it goes backwards!

        Neal

        • #13985

          [quote:f2806c42d6=\”nwalters\”]
          It seems odd, but it shows 6 hours previous i.e. 3AM, which is NOT GMT.
          Apparently if you take a non-GMT time and try to convert it to GMT, it goes backwards!
          [/quote:f2806c42d6]

          I think what you’re seeing is being a victim of a fairly nasty issue in the way the .NET Frameworks treats datetimes. Basically, it always wants to have them in local time, which particularly causes problems when XmlSerialization is involved (and hence XmlConvert.ToString()). Here’s a couple of articles with some info:

          [url]http://blogs.msdn.com/brada/archive/2004/04/13/112784.aspx[/url]
          [url]http://blogs.msdn.com/bclteam/archive/2005/03/07/387677.aspx[/url]

          Probably what happens is that BizTalk Reads your datetime, realizes it has a -6 hours offset, and uses that to compute what the local time for that would be. And then gives you that.

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.