我希望根据月份和年份从开始到结束循环日期。例如
Month is 12 and year is 2014.
01 Dec 2014
02 Dec 2014
03 Dec 2014
.
.
31 Dec 2014
答案 0 :(得分:1)
使用Recursive CTE
with CTE
as
(
select N=0
UNION ALL
select N+1 from CTE where N<30
)select CONVERT( CHAR(12),DATEADD(D,N,CAST('2014-12-01' as DATE)),106) from CTE