我的表中的日期字段是datetime类型的
现在我想查询某月的所有信息 请问sql语句该怎么写啊

解决方案 »

  1.   

    SELECT * FROM TB
    WHERE YEAR(DATE)=2010 AND MONTH(DATE)=6
      

  2.   

    datename
    datepartorconvert(varchar(7),字段,120)
      

  3.   

    select * from tb where convert(varchar(10),s_date,120)='2010-06-20'
      

  4.   

    select *
    from tb
    where convert(varchar(7),col,120)='2010-05'
    --or
    select *
    from tb
    where year(col)=2010 and month=5
      

  5.   

    select *  from  T  where convert(,char(7),日期字段,120) ='yyyy-mm''yyyy-mm' 为参数
      

  6.   


    select * from ta where year(col)='' and month=''
      

  7.   


    select * from T where convert(char(7),日期字段,120) ='yyyy-mm'
      

  8.   


    select * from tb where convert(varchar(4),dt,120)=你要查的年数 and month(dt)=5
      

  9.   

    select * from tb where convert(varchar(4),dt,120)=你要查的年数 and month(dt)=6
      

  10.   

    select * from tb  where year(col)=2010 and month=5
      

  11.   

    比较两个时间的月份差异想同的数据就是你想要的
    select * from tabel1 where  datediff(month,date1,@date2) = 0