当前位置: 代码迷 >> Sql Server >> 查询在这一星期之内的数据,该如何解决
  详细解决方案

查询在这一星期之内的数据,该如何解决

热度:22   发布时间:2016-04-27 20:35:43.0
查询在这一星期之内的数据
查询在这一星期之内的数据

------解决方案--------------------
declare @t table(id int,dt datetime)
insert @t
select 1, '2007-06-08 ' union all
select 2, '2007-06-09 ' union all
select 3, '2007-06-10 ' union all
select 4, '2007-06-11 ' union all
select 6, '2001-06-11 ' union all
select 5, '2007-06-12 '


select * from @t where datepart(week,dt) = datepart(week,getdate()) and datepart(year,dt) = datepart(year,getdate())
  相关解决方案