I\'m trying to convert a date in yyyymmdd format to yyyy-mm-dd with the following code:
tdrDate = DateTime.ParseExact(dateString, \"yyyymmdd\", null).ToStrin
The format string is case-sensitive, so "mm" is different to "MM". You are parsing minutes ("mm"), which is why the value of months ("MM") is always at the default value of 1.
It should be:
DateTime.ParseExact(dateString, "yyyyMMdd", null).ToString("yyyy-MM-dd");
Capital 'MM' in the first date format string.
A handy reference: SteveX Compiled: String formatting in C#