如何获取一年中某一周是 几号到几号
比如说今年的第44周
我要获取第44周
是10.28号-11.3号(周一到周日)
[解决办法]
Refer this:
http://www.cnblogs.com/insus/tag/Week/
[解决办法]
DateTime dt = new DateTime(2013, 1, 1).AddDays(-1);
DateTime d1 = dt.AddDays((44 - 1) * 7);//2013-10-28
DateTime d2 = d1.AddDays(6);//2013-11-03
DateTime firstDay = new DateTime(2013, 1, 1);
//第一天周几
int firstdayofweek = Convert.ToInt32(firstDay.DayOfWeek);
//第一个周一(周一对应1)
DateTime firstMonday = firstdayofweek <= 1 ? firstDay.AddDays(1 - firstdayofweek) :
firstDay.AddDays(8 - firstdayofweek);
//第44周的日期
DateTime targetDay = firstMonday.AddDays(7 * (44 - 2));
Console.Write(targetDay.ToShortDateString());
Console.ReadKey();