DECLARE @dtStart DATETIME = '2019-09-20'
DECLARE @dtEnd DATETIME = '2019-10-08'

IF OBJECT_ID('tempdb..#tempDate') IS NOT NULL
	DROP TABLE #tempTable

CREATE TABLE #tempDate
(
	  dDate DATETIME
)


WHILE (@dtStart < @dtEnd) 
BEGIN
    INSERT #tempDate(dDate) VALUES(@dtStart)
    SET @dtStart = DATEADD(day, 1, @dtStart)
END

SELECT * FROM #tempDate d (NOLOCK)
DECLARE @dtStart DATETIME = '2019-09-20'
DECLARE @dtEnd DATETIME = '2019-10-08'


DECLARE @tempDate TABLE
(
	  dDate DATETIME
)


WHILE (@dtStart < @dtEnd) 
BEGIN
    INSERT @tempDate(dDate) VALUES(@dtStart)
    SET @dtStart = DATEADD(day, 1, @dtStart)
END

SELECT * FROM @tempDate 
Last modified: October 8, 2019

Author

Comments

Write a Reply or Comment