sql server 中查找从上个月的这天到今天的数据
比如从5月8号到今天6月8号的数据怎么写,要考虑到12月3号到1月3号这样的情况。

解决方案 »

  1.   

    select * from table where datediff('m', getdate(), 字段名) = 1
      

  2.   

    select * from table where datediff('m', getdate(), 字段名) <= 1
      

  3.   

    select * from 表名 where  
    convert(int,日期字段)>20051212 and  convert(int,日期字段)<20051230
    或select * from 表名 where &#63519;&#63210;日期字段 between'2005/12/12 and 2005/12/30
      

  4.   

    可以用加减运算来计算时间的啊~~~如果一个月是30天你就用当前日期-30,嘛~~~只是要在程序中控制了~~~
    var d,d1:tdate;
        d:=date;
        d1:=d-(具体的天数);//方法笨笨的~~呵~
      

  5.   

    同意  边学Delphi 边要饭的
      

  6.   

    apartst(一元http://www.ooland.com)  应该是正确的
      

  7.   

    select * from table
    where 字段名>=dateadd(mm,-1,getdate()),注意时分秒的差自己去掉