获取一周内的数据

获取一周内的数据:     

1 DateTime givenDate = DateTime.Today;
2 DateTime startOfWeek = givenDate.AddDays(-1 * (int)givenDate.DayOfWeek);
3 DateTime endOfWeek = startOfWeek.AddDays(7);

EF获取昨天的数据:

DateTime sdt = DateTime.Now.Date.AddDays(-2);
DateTime dt = DateTime.Now.Date.AddDays(-1);
model.YesterdayOrderCount = orderQuery.Count(p => p.SuccessTime >= sdt && p.SuccessTime <= dt);

 

posted @ 2015-01-19 16:39  carsick_cars  阅读(239)  评论(0编辑  收藏