如果TIME是datetime数据类型:
select * from A where datepart(year,TIME) = 2101 and datepart(month,TIME) = 2
或者
select * from A where TIME between "2010-2-1" and "2010-2-28 23:59:29"
如果TIME是字符类型
select * from A where TIME between "20100201" and "20100228"
where TIME >='2010-2-1' and TIME <'2010-3-1'
或者
where year(TIME)=2010 and month(TIME)=2
-------------------------------------
时间类型转换为字符型用like 效率会低哦
如果TIME是datetime型的
where convert(varchar,TIME,112) like '201002%'
如果TIME是字符型的
where TIME like '201002%'
select * from 表A where to_char(time,'YYYYMM') like '%201002%'