DECLARE @StartTime AS DATETIME
SET @StartTime= '2016-5-10 '
DECLARE @t
TABLE(dDate DATETIME) --计算连续时间
WHILE @StartTime <= '2016-5-13 '
BEGIN
INSERT INTO @t SELECT @StartTime
SET @StartTime=Dateadd(day,1,@StartTime)
END
SELECT * FROM @t
SELECT CONVERT(varchar(100),T0.dDate ,23) FROM @t T0
----------------------------------------
DECLARE @Start NVARCHAR(50) ='2016-05-10';
DECLARE @End NVARCHAR(50) ='2016-12-10';
DECLARE @tempTime AS DATETIME
SET @tempTime= @Start
DECLARE @t
TABLE(dDate DATETIME) --计算连续时间
WHILE @tempTime <= @End
BEGIN
INSERT INTO @t SELECT @tempTime
SET @tempTime= Dateadd(day,1,@tempTime)
END
SELECT CONVERT(varchar(100),T0.dDate ,23) FROM @t T0