By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,722 Members | 1,874 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,722 IT Pros & Developers. It's quick & easy.

array of dates returned from MYSQL

P: n/a
rob
This has been puzzelling me for a couple of weeks now, and just can't figure
it out.

Does anyone know how to return an array of dates from MySQL given the start
date and end date. The database has a rows containing 'start date' and 'end
date' I need an array containing all the days between 'start date' and 'end
date', ie:

Start Date = 15/06/2004
End Date = 17/06/2004

Array returned: 15/06/2004,16/06/2004,17/06/2004

Hope this make sense?... I would love to hear if anyone has done this before
or has any idea's how I can do this.

MySQL 4.0 and PHP 4

Thanks in advance.


Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"rob" <ro*@one01.co.uk> wrote in message
news:cb**********@sparta.btinternet.com...
This has been puzzelling me for a couple of weeks now, and just can't figure it out.

Does anyone know how to return an array of dates from MySQL given the start date and end date. The database has a rows containing 'start date' and 'end date' I need an array containing all the days between 'start date' and 'end date', ie:

Start Date = 15/06/2004
End Date = 17/06/2004

Array returned: 15/06/2004,16/06/2004,17/06/2004

Hope this make sense?... I would love to hear if anyone has done this before or has any idea's how I can do this.


Using mysql only? Hmmm...I guess what you'd need to do is create a table
with sequentially numbered rows starting from 0, then do a cartesian and add
the number to the date using adddate().

SELECT ADDATE(start_date, num) FROM table1, numbers
WHERE num < DATEDIFF(start_date, end_date);
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.