Created
June 24, 2013 20:11
-
-
Save kenny-evitt/5853174 to your computer and use it in GitHub Desktop.
Generate a temporary table of dates from a 'numbers' table. The minimum 'Number' value in the table dbo.Numbers is 1. The "DATEDIFF(...)" expression removes the time portion of the "GETDATE()" function value.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT NumberedDate = DATEADD( day, DATEDIFF(day, 0, GETDATE()) - Number + 1, 0 ) | |
INTO #lastSixtyDays | |
FROM dbo.Numbers | |
WHERE Number < 62; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment