-
-
Save linyongfu2013/94d26b15e9badb8c4d25c4d1300e2ecf to your computer and use it in GitHub Desktop.
Revisions
-
IcedMango created this gist
Dec 16, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ CREATE FUNCTION getRangeMonthList(@beginDate VARCHAR(50), @endDate VARCHAR(50)) RETURNS @table TABLE ( MonthList VARCHAR(20) ) AS BEGIN WITH x AS ( SELECT CAST(@beginDate AS DATE) [Month] UNION ALL SELECT DATEADD(M, 1, [Month]) FROM x WHERE [Month] < CAST(@endDate AS DATE) ) INSERT INTO @table SELECT CONVERT(VARCHAR(7), [Month], 126) AS MonthList FROM x WHERE CONVERT(VARCHAR(7), [Month], 126) < @endDate RETURN END GO