C#获取时间属于第几周
int getWeek(DateTime dt)
{
DateTime time = Convert.ToDateTime(dt.ToString("yyyy") + "-01-01");
TimeSpan ts = dt - time;
int iii = (int)time.DayOfWeek;
int day = int.Parse(ts.TotalDays.ToString("F0"));
if (iii == 0)
{
day--;
}
else
{
day = day - (7 - iii) - 1;
}
int week = ((day + 7) / 7) + 1;
return week;
}