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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -