Datediff的使用(统计本日,昨日,本周,本月)

//统计本日,昨日,本周,本月添加的产品总数

//日期
            DateTime DT = DateTime.Now;
            string day=DT.Date.ToString("yyyy-MM-dd");
            DateTime days = DT.Date;
            //今日新增
            var ToDaypro = db.表.Count(e => SqlFunctions.DateDiff("dd", 添加的日期, day) == 0);
        
       
            //昨日新增
            var Ypro = db.表.Count(e => SqlFunctions.DateDiff("dd", 添加的日期, day) == 1);
         
            //本周新增

//周一
            DateTime dt1 = DateTime.Now.AddDays(0 - DateTime.Now.DayOfWeek);
            //周日
            DateTime dt2 = dt1.AddDays(7);
       
           var Npro = from c in db.XX.ToList()
                      where Convert.ToDateTime(添加的日期) <=dt2 && Convert.ToDateTime(添加的日期) >= dt1
                      select c;
            Npro.Count()
           
        
            //本月新增
            var Mpro = db.XX.Count(e => SqlFunctions.DateDiff("mm", 添加的日期, day) == 0);

上一篇:使用idea上传项目到gitHub


下一篇:使用git工具上传项目到github步骤