110,534
社区成员
发帖
与我相关
我的任务
分享
string str1 = "2014-10-20";
string str2 = "2014-10-25";
DateTime t1 = Convert.ToDateTime(str1);
DateTime t2 = Convert.ToDateTime(str2);
List<DateTime> dateList = new List<DateTime>();
for (DateTime t = t1.AddDays(1); t < t2; t = t.AddDays(1))
{
dateList.Add(t);
}
string str = "";
for (int i = 0; i < dateList.Count; i++)
{
str = str + dateList[i].ToString("yyyy-MM-dd") + " ";
}
MessageBox.Show(str);
DateTime dt1 = DateTime.Parse("2014-10-20");
DateTime dt2 = DateTime.Parse("2014-10-25");
TimeSpan ts = dt2 - dt1;
MessageBox.Show(ts.Days.ToString());