SQL query to return the dates between the 2 dates

Hello All,

I need the SQL Query that returns All the dates between Two dates.

EG

If the Start date is 06/23/2008 and End date is 06/30/2008

Then
I need the Output of query as

06/23/2008
06/24/2008
06/24/2008
.
.
.
06/30/2008

Please kindly provide me the Query AS soon as possible

Thanks in advance

WHERE datefield BETWEEN ‘2008-06-23’ AND ‘2008-06-30’

Hello guido2004,

Actually i don’t work as the I don’t want the dates between two dates from database.
In the database only two fields as Startdate and Enddate is there now i want the dates between Startdate and Enddate which are not in the database

Please kindly provide me the query

Thanks in advance

I see. Don’t know if that’s possible with SQL. Maybe you should do that with your programming/scripting language?

Hello guido2004,

I can do it by scripting but i want it through query as i have to display all events in the event calender for these dates which are in between the start date and end date.

Thanks in advance

You could do it if you had a calendar table, with all dates in it.
But in my opinion you might as well get all events between the two dates, and then make your script loop through the dates and the events and create the event calender.

of course it’s possible :wink:

see http://www.sitepoint.com/forums/showthread.php?t=445450

this one’s easier because it wants every date, so you can remove the WHERE condition for day of week

Very nice. Learning something new every day :slight_smile:
At least I guessed part of the solution when I said another table was needed :shifty: