ok, i know this is old and you have a solution, but I am bored and looked into this anyway :)
I really like to keep things simple, so there is no real need for the Regex or for the DateTime:
f = "171005_010"; //assuming this is ALWAYS the format
try {
//if f is shorter than 6, one of these substring will throw an exception
string yy = f.Substring(0, 2);
string mm = f.Substring(2, 2);
string dd = f.Substring(4, 2);
//since there is only a 2-digit year in f, must assume only 20xx in set
return "20" + yy + "-" + mm + "-" + dd;
} catch (ArgumentOutOfRangeException ee) {
return null;
}
ok, i know this is old and you have a solution, but I am bored and looked into this anyway :)
I really like to keep things simple, so there is no real need for the Regex or for the DateTime:
```
f = "171005_010"; //assuming this is ALWAYS the format
try {
//if f is shorter than 6, one of these substring will throw an exception
string yy = f.Substring(0, 2);
string mm = f.Substring(2, 2);
string dd = f.Substring(4, 2);
//since there is only a 2-digit year in f, must assume only 20xx in set
return "20" + yy + "-" + mm + "-" + dd;
} catch (ArgumentOutOfRangeException ee) {
return null;
}
```
(post is archived)