Just use the DateTime.ParseExact
method:
string date = "20121004";
string result = DateTime.ParseExact(date, "yyyyMMdd",
CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
This also provides the advantage of validating the date before reformatting it with the hyphens. ParseExact
throws an exception you can catch, if the date is not in valid range, or the format does not match.