季节计算脚本
DECLARE @date VARCHAR(10), @day INT
SET @date=CONVERT(VARCHAR(10),GETDATE(),112)
SET @day=(DATEPART(WEEK,SUBSTRING(@date,1,4)+'1231')-48+((DATEPART(WEEKDAY,SUBSTRING(@date,1,4)+'0101')-1)+3)/7)*7
SELECT
y=YEAR(DATEADD(DAY,-@day,@date))
,s=(DATEPART(WEEK,DATEADD(DAY,-@day,@date))-1)/13+1
,w=(DATEPART(WEEK,DATEADD(DAY,-@day,@date))-1)%13+1
,d=DATEPART(WEEKDAY,@date)-1
y,年;
s,季节;
w,周;
d,天;
例如,今天是2012年春季第9周第4天,大约是这样哦。