c# - Comparing two dates by week in a .NET entity framework LINQ query? -
is there easy way of comparing weeks in 2 dates this...
var times = (from d in db.timeset d.eventdate.week) == datetime.thisweek && d.employee.username == username select d).tolist();
public static int getweeknumber(datetime date) { cultureinfo ci = cultureinfo.currentculture; int weeknum = ci.calendar.getweekofyear(date, calendarweekrule.firstfourdayweek, dayofweek.monday); return weeknum; }
and
var times = (from d in db.timeset getweeknumber(d.eventdate) == getweeknumber(datetime.now) && d.employee.username == username select d).tolist();
you might want calendarweekrule pick 1 fits needs.
Comments
Post a Comment