开发者

matching event date column to todays date

开发者 https://www.devze.com 2023-02-12 22:49 出处:网络
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?

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

精彩评论

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