如何实现分别按年,年月,年月日查询呀???

解决方案 »

  1.   

    select * from t_form where year(c_date)='2007'
      

  2.   

    select * from t_form where convert(varchar(10),year(c_date))+convert(varchar(10),month(c_date))='20076'
      

  3.   

    在SQL语句中将年月日按需要的查询部分截取出来,数据量很大的话可考虑分别做字段
      

  4.   

    Select yyyy from table where yyyy='2008'
    Select (yyyy+mm) from table where yyyy='200803'
    Select (yyyy+mm+dd) from table where yyyy='20080326'
      

  5.   

    年 select * from tbname where datename(yy,字段)='2008'
    年月 select * from tbname where convert(varchar(7),字段,120)='2008-01'
    年月日 select * from tbname where convert(varchar(10),字段,120)='2008-01-01'