开发者

matching event date column to todays date

I am trying to get records that match with todays date(not time) but the t开发者_开发技巧imes are different so no match? Should I use substring on the e.eventdate?

  List<Time> time = db.TimeSet.Where(e
=> e.Employee.Username == username && 
                e.EventDate == DateTime.Today).ToList();


Have you tried using the Date property on EventDate?

Something like

e.EventDate.Date == DateTime.Today


According to: http://msdn.microsoft.com/en-us/library/bb738681.aspx

You should be able to do:

db.TimeSet.Where(e => e.EventDate.Day == DateTime.Today.Day && e.EventDate.Month == DateTime.Today.Month && e.EventDate.Year == DateTime.Today.Year)


Try this

List time = db.TimeSet.Where(e => e.Employee.Username == username && e.EventDate.Date == DateTime.Today.Date).ToList();

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜