在我的数据库中,我有一个这样的日期:
01-03-2022 00:00:00
07-03-2022 00:00:00
05-03-2022 00:00:00
012-03-2022 00:00:00
013-03-2022 00:00:00
014-03-2022 00:00:00
每周周一之后,我需要过去一周的日期才能提取
我正在重复这样的日期:
foreach(var item in model.dates)
{
// item.Date has all dates
// I don't know how to get dates here
}
我只想拿那些日期,我该怎么做?
if (DateTime.Today.DayOfWeek == DayOfWeek.Monday)
{
DateTime weekStart = DateTime.Today.AddDays(-7);
DateTime weekEnd = DateTime.Today.AddDays(-1);
var result = model.Dates.Where(x => weekStart <= x && weekEnd >= x);
}