467,104 Members | 1,032 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,104 developers. It's quick & easy.

array of dates returned from MYSQL

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
  • viewed: 1749
Share:
1 Reply
"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.

Similar topics

3 posts views Thread by Mark Stevens | last post: by
7 posts views Thread by Tony Clarke | last post: by
5 posts views Thread by duikboot | last post: by
16 posts views Thread by frizzle | last post: by
12 posts views Thread by zzapper | last post: by
3 posts views Thread by Brian Smither | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.