34,590
社区成员
发帖
与我相关
我的任务
分享
create table #Time(date datetime)
insert #Time
select '2011-04-16' union all
select '2011-04-17' union all
select '2011-04-18' union all
select '2011-04-19' union all
select '2011-04-20' union all
select '2011-05-07' union all
select '2011-05-08' union all
select '2011-05-09' union all
select '2011-05-11'
declare @Today as datetime
set @Today=getdate()
select * from #Time where convert(nvarchar(10),date,120)=convert(nvarchar(10),@Today,120) --今天
select * from #Time where convert(nvarchar(10),date,120)=convert(nvarchar(10),dateadd(day,-1,@Today),120) --昨天
select * from #Time where datepart(week,date)=datepart(week,@Today) --本周