您的位置:1010cc时时彩经典版 > 1010cc安卓版 > SQLServer查询最近一天,本季度的数据的sql语句

SQLServer查询最近一天,本季度的数据的sql语句

发布时间:2019-08-15 09:28编辑:1010cc安卓版浏览(171)

    最近一个月:

    三天 select from T_news where datediff(day,addtime,getdate())<= 2 and datediff(day,addtime,getdate())>= 0*

    一周 "SELECT FROM T_news WHERE (DATEPART(wk, addtime) = DATEPART(wk, GETDATE())) AND (DATEPART(yy, addtime) = DATEPART(yy, GETDATE()))*";

    select * from T_news where datediff(day,addtime,getdate())<= 2 and datediff(day,addtime,getdate())>= 0

    一季度 select * from T_news where DATEPART(qq, addtime) = DATEPART(qq, GETDATE()) and DATEPART(yy, addtime) = DATEPART(yy, GETDATE())

     

    select * from T_news WHERE (DATEPART(yy, addtime) = DATEPART(yy, GETDATE())) 
    AND ((DATEPART(mm, addtime) = DATEPART(mm, GETDATE())) OR (31-DATEPART(DD,addtime) DATEPART(DD, GETDATE()))<=31)

    一周 select from T_news WHERE (DATEPART(wk, addtime) = DATEPART(wk, GETDATE())) AND (DATEPART(yy, addtime) = DATEPART(yy, GETDATE()))*

     

    select * from T_news WHERE (DATEPART(wk, addtime) = DATEPART(wk, GETDATE())) AND (DATEPART(yy, addtime) = DATEPART(yy, GETDATE()))

    一天 select from T_news where datediff(day,addtime,getdate())=0*

    三天1010cc时时彩经典版, "select from T_news where datediff(day,addtime,getdate())<= 2 and datediff(day,addtime,getdate())>= 0*";

    本季度:

    注意:此时不能用 datediff 差值为7,因为,datediff只表示间隔数

    一月"SELECT * FROM T_news WHERE (DATEPART(yy, addtime) = DATEPART(yy, GETDATE())) AND (DATEPART(mm, addtime) = DATEPART(mm, GETDATE()))";

    本文由1010cc时时彩经典版发布于1010cc安卓版,转载请注明出处:SQLServer查询最近一天,本季度的数据的sql语句

    关键词: