The dropdown has values as 05 May 2014 , 12 May 2014 . When I try to parse it , I get error as String was not recognized as a valid DateTime
So these are entries in the DropDownList
:
05 May 2014
12 May 2014
21 Apr 2014
and you want to parse it to a real DateTime
.
Then you can use DateTime.ParseExact
:
// presuming "21 Apr 2014" is DrpDwnGetPayPeriod.SelectedValue
DateTime weekStartDate = DateTime.ParseExact("21 Apr 2014", "dd MMM yyyy", CultureInfo.InvariantCulture);
Since you're using three letter abbreviations for month names you need to use MMM
.