自动生成日期表

背景:自动生成日期表

 

 

DECLARE @year INT=year(getdate());
---DECLARE @year INT=year(:endTime);
WITH t AS (SELECT CAST( CAST(@year AS VARCHAR(4)) + '-1-1' AS DATE) AS Dt
UNION ALL SELECT DATEADD(DAY,1, t.Dt) FROM t WHERE t.Dt<CAST(@year AS VARCHAR(4)) + '-12-31')

select * from t
option (maxrecursion 400)

 

上一篇:Perl module: Time::Moment


下一篇:DT时代,优秀的BI工具应该具备哪些功能