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