where 申报日期后面怎么写
我想查询如2004年8月及2004年整年的记录

解决方案 »

  1.   

    select * from table where convert(char(4),data,120)='2004'
    select * from table where convert(char(7),data,120)='2004-08'
      

  2.   

    select * from table where datename(yyyy,data)='2004' and datename(m,data)='8'
    select * from table where datename(yyyy,data)='2004'
      

  3.   

    如果是char型, flashasp(flashasp) 的方法可以实现你的要求
    如果是datetime型
      select * from table where year(字段名)='2004' and month(字段名)='8'
      select * from table where year(字段名)='2004'
      

  4.   

    select * from table where datename(yyyy,data)='2004' and datename(m,data)='8'
    select * from table where datename(yyyy,data)='2004'
      

  5.   

    select * from table where year(date)=2004 and month(date)=8
    这样不方便点吗?