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