首页 > 代码库 > 动态生成日期记录

动态生成日期记录

DECLARE @mindate DATETIME;  DECLARE @maxdate DATETIME;  SET @mindate = DATEADD(MONTH, -11, GETDATE());SET @maxdate = GETDATE();WITH    temptab ( date )          AS ( SELECT   @mindate               UNION ALL               SELECT   DATEADD(m, 1, temptab.date) AS date               FROM     temptab               WHERE    DATEADD(m, 1, temptab.date) <= @maxdate             )    SELECT  *    FROM    temptab;  

  技术分享

 

动态生成日期记录