That question may be already been answered here, but I could not find any answers. I'm trying to to convert the string 25APR18 to 2018-04-25.
I tried to do the following:
DateTime.ParseExact("25APR18", "yyyy-mm-dd", CultureInfo.InvariantCulture);
But it does not convert and gives me the error saying "String was not recognized as a valid DateTime."
I was not able to find the right solution.
Any suggestions?
DateTime.ParseExact
. There are no dashes in this string, so why useyyyy-mm-dd
?ParseExact
without understanding the nature of the wordExact
. The right format for that date string would be"ddMMMyy"
, tested and works.DateTime.ParseExact
, the format you specify is the display format of the string you want to parse.