求大神帮忙解决日期控件问题
string myStrYear, myStrMonth, myStrDay, myStrDay1;
string myStrFileName = "";
myStrYear = myDTTime.Year.ToString().Substring(2, 2);
if (myDTTime.Month > 9)
{
myStrMonth = myDTTime.Month.ToString();
}
else
{
myStrMonth = "0" + myDTTime.Month.ToString();
}
if (myDTTime.Day > 9)
{
myStrDay = myDTTime.Day.ToString();
}
else
{
myStrDay = "0" + myDTTime.Day.ToString();
}
d = Convert.ToInt32(myStrDay) - 1;
myStrDay1 = Convert.ToString(d);
myStrFileName = myStrYear + myStrMonth + myStrDay1 ;
------解决方案--------------------比如:
C# code
DateTime tody = DateTime.Now;
DateTime yesdy = tody.AddDays(-1);
Console.WriteLine(yesdy.ToString());
------解决方案--------------------
------解决方案--------------------
------解决方案--------------------
[code=C#][/code]
DateTime dt=DateTime.Now;
//前一天
dt.AddDays(-1);
//前一周
dt.AddDays(-7);
//前一月
dt.AddMonths(-1);
//前一年
dt.AddYears(-1);