每一行都有一个BookedMonth和一个ReportingMonth。我想返回ReportingMonth比BookedMonth大2个月的行。
ReportingMonth BookedMonth
2016-01-01 00:00:00 2015-11-01 00:00:00
2016-01-01 00:00:00 2015-12-01 00:00:00
2016-01-01 00:00:00 2016-01-01 00:00:00
WHERE
DATEDIFF,BookedMonth,ReportingMonth,2
答案 0 :(得分:0)
类似的东西:
select * from table where datediff(month, ReportingMonth, BookedMonth) > 2;
修改强>
或者更好......请在下面发表评论:
select * from table where ReportingMonth > dateadd(month, 2, BookedMonth);