日期:2014-05-18 浏览次数:20865 次
DateTime dateStart = new DateTime(2000, 01, 01); DateTime dateEnd = dateStart; do { dateEnd = dateEnd.AddMonths(1); } while (dateEnd.Year <= 2005 && dateEnd.Month <= 05);
------解决方案--------------------
int year1 = Convert.ToDateTime(startdate).Year; int year2 = Convert.ToDateTime(enddate).Year; int month1 = Convert.ToDateTime(startdate).Month; int month2 = Convert.ToDateTime(enddate).Month; //计算总月份 int month = (year2 - year1) * 12 + (month2 - month1);
------解决方案--------------------
public static int GetYearWeekCount(int strYear)
{
string returnStr = "";
System.DateTime fDt = DateTime.Parse(strYear.ToString() + "-01-01");
int k = Convert.ToInt32(fDt.DayOfWeek);
if (k == 1)
{
int countDay = fDt.AddYears(1).AddDays(-1).DayOfYear;
int countWeek = countDay / 7 + 1;
return countWeek;
}
else
{
int countDay = fDt.AddYears(1).AddDays(-1).DayOfYear;
int countWeek = countDay / 7 + 2;
return countWeek;
}
}
循环添加月份