How do I convert an XML DateTime in a web method
I am passing a string into a webservice that contains a date formatted as "2010-08-26T00:00:00". this format is required by the infoPath form that passes this through XML.
When I try to convert the date into a usable date in the web method I get an error "System.FormatException: String was not recognized as a valid DateTime" when I run the application (InfoPath form).
The partial code for the web method looks like:
public string CheckDuplicates(string StartDate)
{
DateTime datStartDate = DateTime.Parse(StartDate);
(the error occurs on the first line of the method doing the parse)
The code works correctly if I hard code the line like:
DateTime datStartDate = DateTime.Parse("2010-08-26T00:00:00");
The application is an InfoPath form that calls this web service and passes the string, I can view the string and verify that it matches the format I indicated previously but the web method gets confused.
Is there something wrong in my code or the way I am using Parse?