表1
id dates
01 23/02/2011
02 24/04/2011
03 26/08/2011
...
我想从table1中选择id,如果超过6个月的日期。
tabl1的预期输出
id日期
01 23/02/2011 'Dates is older than 6 month
02 24/04/2011 'Dates is older than 6 month
如何进行查询
需要查询帮助
答案 0 :(得分:5)
select id, dates
from Table1
where dates < dateadd(month, -6, getdate())
答案 1 :(得分:1)
select id from table1 where datediff(m, dates, getdate()) >= 6