Hi,
you can make use of
DATEADD
function of SQL.
refer below links for more on DATEADD.
DATEADD-MSDN[
^]
SQL Server DATEADD() Function[
^]
So, try like below.
DECLARE @StartDate DATETIME, @EndDate DATETIME
CREATE TABLE @Dates (DateCol DATETIME)
SET @StartDate = '1/1/2000'
SET @EndDate = '1/12/2020'
INSERT INTO @Dates Values(@StartDate)
WHILE @StartDate < @EndDate
BEGIN
SET @StartDate = DATEADD(day,1,@StartDate)
INSERT INTO @Dates Values(@StartDate)
END
INSERT INTO @Dates Values(@EndDate)
SELECT DateCol FROM @Dates
hope it helps.