// 获取本周的周一 public string GetThisWeekMonday() { DateTime date = DateTime.Now; DateTime first = System.DateTime.Now; switch (date.DayOfWeek) { case System.DayOfWeek.Monday: first = date; break; case System.DayOfWeek.Tuesday: first = date.AddDays(-1); break; case System.DayOfWeek.Wednesday: first = date.AddDays(-2); break; case System.DayOfWeek.Thursday: first = date.AddDays(-3); break; case System.DayOfWeek.Friday: first = date.AddDays(-4); break; case System.DayOfWeek.Saturday: first = date.AddDays(-5); break; case System.DayOfWeek.Sunday: first = date.AddDays(-6); break; } return first.ToString("yyyy-MM-dd"); } // 获取本周的周日 public string GetThisWeekSunday() { DateTime date = DateTime.Now; DateTime last = System.DateTime.Now; switch (date.DayOfWeek) { case System.DayOfWeek.Monday: last = date.AddDays(6); break; case System.DayOfWeek.Tuesday: last = date.AddDays(5); break; case System.DayOfWeek.Wednesday: last = date.AddDays(4); break; case System.DayOfWeek.Thursday: last = date.AddDays(3); break; case System.DayOfWeek.Friday: last = date.AddDays(2); break; case System.DayOfWeek.Saturday: last = date.AddDays(1); break; case System.DayOfWeek.Sunday: last = date; break; } return last.ToString("yyyy-MM-dd"); }