想要查询上个月29日到这个月28日的数据,搜索条件应该怎么写?

解决方案 »

  1.   

    select * from ta where date bewteen '2006-12-29 00:00:00'and '2007-01-28 23:59:59'
      

  2.   

    where 日期〉=上月29日 and 日期<=本月28日??
      

  3.   

    where 日期字段>='2006-09-29' AND 日期字段<'2006-10-29' 
    字段是日期类型,建议用>=\<
      

  4.   

    select * from table where datefield>=cast(convert(char(8),dateadd(m,-1,getdate()),120)+'29' as datetime) and datefield<=cast(convert(char(8),getdate(),120)+'28' as datetime);
      

  5.   

    where datecolumn between '2002-10-29' and '2003-11-29'
    大体意思是上面的,可能数据类型没有匹配好,搂主自己调整吧。
      

  6.   

    --tryselect * from tbName
    where colName>=dateadd(month, -1, convert(char(8), getdate(), 120)+'29')
    and colName<convert(char(8), getdate(), 120)+'29'