问个好像是 有关于时间之间 差的问题。
就是想做个生日提醒,比如 某人生日 2012-05-20 ,那么5天之内都能查询 出来 也就是 从 2012-05-15 日 就能查出。这个SQL 怎么写呀。郁闷
[解决办法]
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