Friday, April 20, 2012

String was not recognized as a valid DateTime

I want to add a date in session (date1) like this:



Session["DateLesson"] = date1.ToString("dd.MM.yyyy");


Now from the session I want take this value:



var asd = Session["DateLesson"];
/*asd = "20.04.2012"*/
var datelesson = DateTime.Parse((string) asd);


And it gives me this exception:



FormatException not recognized as a valid DateTime





No comments:

Post a Comment