表格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

如何进行查询

需要查询帮助

===============>>#1 票数:5 已采纳

select id, dates
from Table1
where dates < dateadd(month, -6, getdate())

===============>>#2 票数:1

select id from table1 where datediff(m, dates, getdate()) >= 6

  ask by Gopal translate from so

未解决问题?本站智能推荐: