SQL日期处理的几个解决方案
1 日期比较几种方案 www.2cto.com
1.0 第一种方案 select * from data0048 where year(tdate)=2013
消耗时间06秒
记录数:224876
1.1 第二种方案 select * from data0048 with(nolock) where DATEDIFF(year,tdate,getdate())=0
消耗时间05秒
记录数:224903
1.2 第三种方案 select * from data0048 with(nolock) where datepart(year,tdate)=2013
消耗时间06秒 www.2cto.com
记录数:224971
1.3 第四种方案 select * from data0048 with(nolock) where dateName(year,tdate)=2013
消耗时间06秒
记录数:224971
1.4 第五种方案select * from data0048 with(nolock) where tdate between '2013-01-01' and getdate()
消耗时间06秒
记录数:224992
1.5 第六种方案 select * from data0048 with(nolock) where CONVERT(varchar(4), tdate, 23)=2013
消耗时间06秒
记录数:224992