本帖最后由 AcHerat 于 2010-12-01 17:17:06 编辑

解决方案 »

  1.   

    select * from tab1 where data<'2010-11-01'
      

  2.   

    select * from tab1 where data<'2010-11-01'
      

  3.   


    2010年10月份这个是个动态日期型参数,有可能它的值为 2010-10-01 或者 2011-04-23,但查询仍然按2010年10月份或2011年4月份来查,不管dd ,这种情况下该怎么用sql语句查询。
      

  4.   


    select * from tab1 where month(data) between 0 and 10
      

  5.   

    之前做的时候一直在用year()和month()来控制,有没有更加优化简洁的???做冷板凳!
      

  6.   


    select * from TTTT where month(data) between 0 and 10   and year(data)<=2010
      

  7.   

    select * from tab1 where data<DATEADD(month, DATEDIFF(month, '', '2010-11-8'), '')
      

  8.   

    select * from tab1 where convert(varchar(10),data,23) < '2010-11-01'
    习惯将日期转换成字符再进行比较 这样简单些
      

  9.   

    给个日期 '2010-10-8'  下面查询的是2010年10月份之前包含10月份的记录select * from tab1 where data < DATEADD(month, 1+DATEDIFF(month, '', '2010-10-8'), '')
      

  10.   

    select * from tb where convert(varchar(7),datetime,120)<convert(varchar(7),'2010-11-01',120)
      

  11.   

    本帖最后由 josy 于 2010-12-01 21:38:00 编辑