有什么好办法求今天的前三天的日期?
各位:
如题,有什么好办法?
------解决方案--------------------AddDays(-1)
AddDays(-2)
DateTime.AddDays()
------解决方案--------------------Data.Today.Date.AddDays(-3)
基本上这样吧!
------解决方案--------------------DateTime.AddDays(-3)
------解决方案--------------------dt.AddDays(-3).ToString( "yyyyMMdd ")
------解决方案--------------------String strDt = "20070105 ";
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);
Console.WriteLine( "result={0} ", dt2.ToString( "yyyyMMdd "));
Console.ReadLine();