日期:2014-05-18 浏览次数:20531 次
declare @t table(name nvarchar(20),IDate datetime) insert into @t select 'name1','2012/05/17' union all select 'name2','2012/05/26' select * from @t where IDate between dateadd(day,-5,getdate()) and getdate()
------解决方案--------------------
比如人事表hr,有个字段是出生日期birthdate,那么
select * from hr where datediff(day,GETDATE(),ltrim(YEAR(GETDATE()))+right(CONVERT(varchar(10),birthdate,120),6))<5