.....   where   diffdate([m],senddatetim,getdate())=0     (这个月)   
    
  或者:month(senddatetime)-month(getdate())=0   (这个月)   
    
  其余依此类推

解决方案 »

  1.   

      
      '这个月   
      select   *   from   表名   where   convert(char(7),SendDateTime,120)=convert(char(7),getdate(),120)   
        
      '上个月   
      select   *   from   表名   where   convert(char(7),SendDateTime,120)=convert(char(7),dateadd(m,-1,getdate()),120)   
        
      '近一个月   
      select   *   from   表名   where   datediff(d,SendDateTime,getdate())<=30   
      

  2.   

    oracle的
    如果是从当前时间到前一个月的这个时候之间的记录总条数:select count(1)
      from uis_md_stcustom u
     where firsttime between add_months(sysdate,-1) and sysdate;如果是求当前时间的前面一个月的内的记录总条数:select count(1)
      from uis_md_stcustom u
     where to_char(firsttime,'mm') = to_char(add_months(sysdate,-1),'mm');
      

  3.   

    取时间字符串today.day 然后在SQL里面使用模糊匹配吧!