EF日期、年、月比较

using System.Data.Entity;

比较值

DateTime comparedate = DateTime.Now;

//比较本年

int count = appservice.Where(q => SqlFunctions.DateDiff("year", t.CreateTime, date) == 0).Count();

//比较本月

int count = appservice.DbSet.Where(q => SqlFunctions.DateDiff("month", t.CreateTime, date) == 0).Count();


//本较是否为同一天
int count = appservice.DbSet.Where(q => SqlFunctions.DateDiff("day", t.CreateTime, date) == 0).Count();

猜你喜欢

转载自www.cnblogs.com/Anthony518/p/10956844.html
今日推荐