给你一个获取当前周的开始日期和结束日期的小例子.//一周开始时间和结束时间
DateTime dtWeekSt;
DateTime dtWeekEd;
//当前日期
DateTime dtNow = DateTime.Now.Date;
//今天是星期几
int iNowOfWeek = (int)dtNow.DayOfWeek;
if (iNowOfWeek == 0)
{
//按中国的习惯,星期天是最后一天
iNowOfWeek = 7;
}
dtWeekSt = dtNow.AddDays(1 - iNowOfWeek);
dtWeekEd = dtNow.AddDays(7 - iNowOfWeek);
源地址
https://qb.zuoyebang.com/xfe-question/question/790c185c0ef44abf2909b74722cc81df.html