Quickly generate sequence of dates

DECLARE @Dates TABLE ([Date] date)

INSERT INTO @Dates([Date])

SELECT DATEADD(DAY, NUMBER, ‘1 mar 2012’)

FROM (SELECT DISTINCT number FROM master.dbo.spt_values WHERE NAME IS NULL) N

WHERE DATEADD(DAY, NUMBER, ‘1 mar 2012’) < ‘1 may 2013’

Advertisements

About fdtki

Sr. BI Developer | An accomplished, quality-driven IT professional with over 16 years of experience in design, development and implementation of business requirements as a Microsoft SQL Server 6.5-2014 | Tabular/DAX | SSAS/MDX | Certified Tableau designer
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s