Skip to content

Instantly share code, notes, and snippets.

@nZac
Created January 15, 2015 18:53
Show Gist options
  • Save nZac/4b8523e543b5e3077a15 to your computer and use it in GitHub Desktop.
Save nZac/4b8523e543b5e3077a15 to your computer and use it in GitHub Desktop.
-- Create a list of dates incremented by month
DECLARE @MinDate DATE = '20120101',
@MaxDate DATE = '20150101';
SELECT TOP (DATEDIFF(MONTH, @MinDate, @MaxDate) + 1)
full_date = DATEADD(MONTH, ROW_NUMBER() OVER(ORDER BY a.object_id) - 1, @MinDate)
FROM sys.all_objects a
CROSS JOIN sys.all_objects b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment