Convert unusual string into date time
- by BlueChippy
I have a system that outputs dates in the format "1{yy}{MM}{dd}" and I am trying to find a good way to parse it back into a real date.
At the moment I am using this:
var value = "1110825";
var z = Enumerable.Range(1,3).Select(i => int.Parse(value.Substring(i, 2))).ToList();
var d = new DateTime(2000 + z[0], z[1], z[2]);
but I'm sure there's a cleaner/more efficient way to do it?
I've tried DT.ParseExact, but can't find a suitable format string to use.