Skip to main content

BizTalk: How To – Convert string DateTime to XML DateTime format (xs:DateTime)

Let’s say in BizTalk Mapper, the source schema has a string field that contains a valid DateTime value and you want it to map to xs:DataTime field.

You may use the following code to convert the string DataTime into xs:DateTime format

static string ConvertDateTimeToXSDDateTime()

{

System.DateTime dateTime = System.DateTime.Now;

string dateTime = System.Xml.XmlConvert.ToString(

dateTime,

System.Xml.XmlDateTimeSerializationMode.RoundtripKind);

return dateTime;

}

Valid XML DateTime looks like this: 2025-06-01T00:00:00

Document Reference: http://msdn.microsoft.com/en-us/library/cc500278.aspx

Comments