获取当前日期周数
int str = new System.Globalization.GregorianCalendar().GetWeekOfYear(System.DateTime.Now, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
根据周得到启示日期和截止日期
private static void GetWeekSpan(out DateTime dtBeginDate, out DateTime dtEndDate, int iWeeks)
{
int iCurrentYear = DateTime.Now.Year;
DateTime dtFirstDate = new DateTime(iCurrentYear, 1, 1);
int iDays = (iWeeks - 1) * 7;
dtFirstDate = dtFirstDate.AddDays(iDays);
int iDaysOfWeek = (int)dtFirstDate.DayOfWeek;
dtBeginDate = dtFirstDate.AddDays(-(iDaysOfWeek - 1)-1);
dtEndDate = dtFirstDate.AddDays(7 - iDaysOfWeek-1);
}
时间: 2024-11-09 08:10:45