DateTime.ParseExact string format exception.

Posted by Rob Ferno on Stack Overflow See other posts from Stack Overflow or by Rob Ferno
Published on 2010-01-04T16:31:31Z Indexed on 2010/05/31 21:33 UTC
Read the original article Hit count: 187

Filed under:
|
|
|

I am trying to convert a string into datetime with the following C# code,

DateTime dTo = DateTime.ParseExact(dateTo, "mm/dd/yyyy", CultureInfo.InvariantCulture);

eachtime I pass dateTo as 1/1/2010 it fails, instead it needs the string to be 01/01/2010.

What string format should I use to support both 01/01/2010 and 1/1/2010?

© Stack Overflow or respective owner

Related posts about c#

Related posts about string