[菜鸟问题]sql查询语句如何根据日期进行比较,显示即将到期记录
sql查询语句如何根据日期进行比较,显示即将到期记录,未来3天比如今天是2007-10-16 我要显示到期日期为2007-10-16、2007-10-17和2007-10-18的所有记录,
意思是查出未来三天内就要到期的记录
declare @a table(times datetime)
insert @a select '2007-10-16'
union all select '2008-10-18'
union all select '2007-10-17'
union all select '2007-12-12'
union all select '2007-10-18'
select * from @a a where times between a.times and dateadd(day,3,getdate())