现在数据表里有一个日期型的字段,让我给拼写成了convert(nvarchar(32),year(时间))+'年'+convert(nvarchar(32),month(时间))+'月'+convert(nvarchar(32),day(时间))+'日' as 时间select出来的数据就是
时间
2011年1月1日
2011年2月1日
2011年2月1日
2011年3月1日
2011年4月1日
2011年1月1日
2011年1月1日现在想模糊查询
select 时间 from 表 where 时间 like '%2011年1月%'
这样怎么查不出来数据了呢
得到的结果是
2011年1月1日
2011年1月1日
2011年1月1日
时间
2011年1月1日
2011年2月1日
2011年2月1日
2011年3月1日
2011年4月1日
2011年1月1日
2011年1月1日现在想模糊查询
select 时间 from 表 where 时间 like '%2011年1月%'
这样怎么查不出来数据了呢
得到的结果是
2011年1月1日
2011年1月1日
2011年1月1日
select 时间 from 表 where CONVERT(VARCHAR(7),时间,112)='201011'
select 时间 from 表 where DATEDIFF(mm,时间,'20110101')=0