表tb,有字段time
要取当前系统时间之前的10天内记录,该怎么写呢?

解决方案 »

  1.   

    select * from tb where time between getdate()-10 and getdate()
      

  2.   

    就是想知道如何获得当前系统前10天的具体日期,想用between .. and getdate()
    不用datediff()...因为影响速度
      

  3.   


    select * from tb where time between dateadd(mm,-10,getdate()) and getdate()
      

  4.   

    dateadd() SQL 日期函数,看看SQL 帮助文档吧。
      

  5.   


    select * from tb where datediff(dd, [time],getdate())<=10-- 如果是10个月内呢? 
    select * from tb where datediff(mm, [time],getdate())<=10
      

  6.   

    select * from tb where time between dateadd(dd,-10,getdate()) and getdate()