3

I have here a date range from
"1/27/2014" - Start
"1/31/2014" - End

Note:

On Figure 1 - that is the data from SQL
On Figure 2 - that is how I want may data to be extracted

How can I do this using SQL query?
Is this possible?

user1647667
  • 1,269
  • 4
  • 14
  • 26
  • What RDBMS do you use (MSSQL,MySQL,Oracle,...)? – valex Feb 04 '14 at 06:14
  • possible duplicate of [Get a list of dates between two dates using a function](http://stackoverflow.com/questions/1378593/get-a-list-of-dates-between-two-dates-using-a-function) – Brett Schneider Feb 04 '14 at 07:15

1 Answers1

2
DECLARE @startDate DATE
DECLARE @endDate DATE
SET @startDate = '1/27/2014'
SET @endDate = '1/31/2014'
;WITH dates AS 
(
    SELECT @startdate as Date 
    UNION ALL
    SELECT DATEADD(d,1,[Date])
    FROM dates 
    WHERE DATE < @enddate
)
SELECT Date from dates

See it live

vhadalgi
  • 7,027
  • 6
  • 38
  • 67