rick
asked on
Loop to go backward 90 days
Trying to get a rolling 90 day for loop to work. First line should be yesterday's date, next line would be day before yesterday's date...until reach 90 days prior. But when I run the following it skips days and doesn't give desired results.
DECLARE @cnt INT = 0;
DECLARE @DATE DATE = GETDATE()
WHILE @cnt < 90
BEGIN
PRINT @DATE
SET @DATE = DATEADD(D, @cnt*-1, @DATE);
SET @cnt = @cnt + 1
END;
Capture.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER