SELECT YEAR(CollectionDate) AS Year, DATEDIFF(quarter, CAST(DATEPART(YEAR, CollectionDate) AS NVARCHAR(4)) + ‘-01-01‘, CollectionDate) + 1 AS Quarter, DATEDIFF(week,CAST(DATEPART(YEAR, CollectionDate) AS NVARCHAR(4)) + ‘-01-01‘, CollectionDate) - DATEDIFF(quarter, CAST(DATEPART(YEAR, CollectionDate) AS NVARCHAR(4)) + ‘-01-01‘, CollectionDate) * 13 + 1 AS Week, CollectionDate
FROM dbo.CollectionInformationList
根据日期类型字段获取年、季度、周(SQLSERVER),布布扣,bubuko.com
原文地址:http://www.cnblogs.com/recent/p/3792276.html