3
我需要從表中獲取數據,其中Date
從下週(從星期一到星期日)從今天的日期開始。獲取下週的日期(C#)
這是我如何獲取數據今天和明天的日期:
public JsonResult GetTodayList()
{
var items = db.Appointments.Where(x => x.Date == DateTime.Today)
.Select(x => new
{
title = x.Title,
time = x.Start_appointment
}).ToList();
return Json(items, JsonRequestBehavior.AllowGet);
}
public JsonResult GetTommorowList()
{
DateTime tommorow = DateTime.Today.AddDays(1);
var items = db.Appointments.Where(x => x.Date == tommorow)
.Select(x => new
{
title = x.Title,
time = x.Start_appointment
}).ToList();
return Json(items, JsonRequestBehavior.AllowGet);
}
我怎樣才能獲得下週日期的數據?
可能重複的[日期時間 - 獲取下一個星期二](https://stackoverflow.com/questions/6346119/datetime-get-next-tuesday) – pinkfloydx33
計算nextMonday和下面的星期一使用愚弄,然後調整你的Where子句'Where (x => x.Date> = nextMonday && x.Date
pinkfloydx33