How do I convert a string to a DateTime in BizTalk 2013R2?

63 Views Asked by At

Most of my BizTalk integrations write data to SQL Server databases. I've got an XLST direct message coming in from another application, and it's mapping to a SQL Server stored procedure.

There are 4 dates that need to be mapped over, and I'm using a mapping functoid to convert them with the following:

public string StringToDatetime(string input)
{
    DateTime dt;

    if (DateTime.TryParse(input, out dt))
    {
        return dt.ToString("yyyy-MM-dd");
    }
    else
    {
        return "";
    }
}

I repeatedly receive the below error no matter what format I try to format dt as (including 8061 format)

Failed to convert parameter value from a String to a DateTime.

System.FormatException: String was not recognized as a valid DateTime.

Input value example;

<date_of_birth>1996-05-04T00:00:00Z</date_of_birth>

Can anyone please advise on the conventional/standard approach to formatting a string datetime for SQL Server consumption?

0

There are 0 best solutions below