取一段连续时间,SQl server 2008可用,其他版本暂时没测试。
1 SELECT DISTINCT
2 CONVERT(VARCHAR(7), DATEADD(month, -number,
3 CONVERT(VARCHAR(11), GETDATE(), 120)), 120) AS NewDate
4 FROM master..spt_values
5 WHERE type = 'p'
6 AND number BETWEEN 0 AND 11
2 CONVERT(VARCHAR(7), DATEADD(month, -number,
3 CONVERT(VARCHAR(11), GETDATE(), 120)), 120) AS NewDate
4 FROM master..spt_values
5 WHERE type = 'p'
6 AND number BETWEEN 0 AND 11