Re: Biztalk 2006 – Problem with Inserting a Date attribute into SQL table: use a custom functoid.

Home Page Forums BizTalk 2004 – BizTalk 2010 Biztalk 2006 – Problem with Inserting a Date attribute into SQL table Re: Biztalk 2006 – Problem with Inserting a Date attribute into SQL table: use a custom functoid.

#17094

A "quick" suggestion is to create a custom DateTime functoid.  I had a similar scenario when moving data into Oracle, which has "wonderful" requirements for date and time formats.  The best part is that once Date/Time is in the xsd:dateTime format, it goes in without fail.  Now the only trouble is stringing together all the functoids in a map to make it work, hence the first solution was to use a scripting functoid.  Of course, since I need this repeatedly, a .NET component and conversion functoid were completed that day.

If you like the idea, the SDK gives enough examples to get started.  The only real work is in creating the few lines it takes to convert the formats.  My solution was to allow a string to accept any valid .NET dateTime format and use the built-in methods to produce the xsd format.  It wasn't pretty and can use some cleanup, but here's the basics…

public string ConvertStringToXsdDateTime(string sDateTime)
{
  DateTime dReturn = new DateTime();
  dReturn = DateTime.Parse(sDateTime);
  return dReturn.ToString("s")
    + TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now).ToString().TrimEnd('0').TrimEnd(':');
}

It works for me in EST/EDT zone, but I haven't attempted real testing.  Hopefully someone will attempt this and find a more "perfect" solution and post it here.

BizTron