|
String strDt = "20170105";
strDt = System.Text.RegularExpressions.Regex.Replace (strDt, @ "(? <Y> ^\d {4}) (? <M>\d {2}) (? <D>\d {2} $)", "$ {Y}-$ {M}-$ {D}");
DateTime dt1 = DateTime.Parse (strDt);
DateTime dt2 = dt1.AddDays (-3);
The
Console.WriteLine ("result = {0}", dt2.ToString ("yyyyMMdd"));
Console.ReadLine (); |
|