码迷,mamicode.com
首页 > Windows程序 > 详细

c# 本周时间查询

时间:2016-06-08 12:35:00      阅读:366      评论:0      收藏:0      [点我收藏+]

标签:

 

 var now = DateTime.Now();
int weeknow = Convert.ToInt32(now.DayOfWeek);
//因为是以星期一为第一天,所以要判断weeknow等于0时,要向前推6天。
weeknow = (weeknow == 0 ? (7 - 1) : (weeknow - 1));
int daydiff = (-1) * weeknow;
//本周第一天
var weekfist = DateTime.Now.AddDays(daydiff);
var weeklast = weekfist.AddDays(7);
query =
query.Where(x => x.StartTime.Date >= weekfist.Date && x.EndTime.Date <= weeklast.Date);

c# 本周时间查询

标签:

原文地址:http://www.cnblogs.com/zhtbk/p/5569478.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!