select * from content where convert(char(7),Pdate,120)>='2000-01'
and  convert(char(7),Pdate,120)<'2003-11'

解决方案 »

  1.   

    convert(char(7),Pdate,120)>='2000-01'中的时间是2000-1而不是2000-01,那该怎么办呢?
      

  2.   

    这样效率会高些:
    select * from content 
    where  cast(Pdate as datetime)
    between cast('2000-1-1' as datetime) and cast('2050-12-1' as datetime)
      

  3.   

    我得数据库中的pdate字段类型为varchar,
    select * from content where convert(char(7),Pdate,120)>='2000-01'
    and  convert(char(7),Pdate,120)<'2003-11'中数据库的字段类型是不是datetime型的?我现在可以查询,但是查询的范围有些错位了