Sawyer
Sawyer

Reputation: 51

SQL separate row for each date between 2 dates

We have a Begin_date and End_date column and I need to have a separate row for each date between the two. For example if begin_date = 11/25/2010 and end_date = 11/26/2010 then it should look like

key: Closed Date:
01 11/25/2010
01 11/26/2010

Upvotes: 0

Views: 747

Answers (1)

Matthew
Matthew

Reputation: 10444

One common method is to create a calendar table of dates and join to it on your criteria. The space to store the data is small and the overhead is low compared to an iterative generation method for every time you want the data.

so in your joins you would add the CalendarTable with Date >= Start_Date and Date <= End_Date

Upvotes: 3

Related Questions