Sql server 2008
获取当前月份:MONTH(GETDATE())
获取当前月份的上个月:MONTH(DATEADD(MONTH,1,GETDATE()))
获取当前月份的下个月:MONTH(DATEADD(MONTH,-1,GETDATE()))
实例SQL语句:(GETDATE()的值为:2012-03-02 14:33:11.670)
select MONTH(GETDATE()) as 当前月,MONTH(DATEADD(MONTH,1,GETDATE())) as 当前月前一月,MONTH(DATEADD(MONTH,-1,GETDATE())) 当前月下一月
执行结果: