首页 > 代码库 > 记录根据当前月生成生前月的天数

记录根据当前月生成生前月的天数

DECLARE @monthDay INT;SET @monthDay = DAY(DATEADD(MONTH, 1, GETDATE()) - DAY(GETDATE())); DECLARE @n INT;SET @n = 1;DECLARE @montDayhstr NVARCHAR(200);SET @montDayhstr =‘‘WHILE @n <= @monthDay    BEGIN                SET @montDayhstr = @montDayhstr +"+ CAST(CONVERT(NVARCHAR(7), DATEADD(MONTH, -0, GETDATE()), 20)AS NVARCHAR(30))            + - + CAST(@n AS NVARCHAR(4))+", ;        SET @n = @n + 1;    END;    PRINT @montDayhstr--SELECT  CAST(CONVERT(NVARCHAR(7), DATEADD(MONTH, -0, GETDATE()), 20)AS NVARCHAR(30))

技术分享

 

记录根据当前月生成生前月的天数