首页 > 数据库技术 > 详细

根据日期类型字段获取年、季度、周(SQLSERVER)

时间:2014-06-17 15:52:19      阅读:1164      评论:0      收藏:0      [点我收藏+]

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

根据日期类型字段获取年、季度、周(SQLSERVER)

原文:http://www.cnblogs.com/recent/p/3792276.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!