当前位置: 代码迷 >> SQL >> SQL 日期处置的几个解决方案
  详细解决方案

SQL 日期处置的几个解决方案

热度:64   发布时间:2016-05-05 12:30:10.0
SQL 日期处理的几个解决方案

1 日期比较几种方案

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

? ???????????????记录数: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

  相关解决方案