What about changing the date format to the actual format your string is? ParseExact
demands an exact representation of the format you enter.
So the solution is to change yyyy-MM-dd
to yyyyMMdd
.
string date = "20141021";
DateTime myDate = DateTime.ParseExact(date, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);