日期:2014-05-19  浏览次数:20449 次

查询在这一星期之内的数据
查询在这一星期之内的数据

------解决方案--------------------
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())