Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

date functions - how to find all available dates in range

Status
Not open for further replies.
Jul 28, 2005
358
FR
Hi,

I have two variables; $fromdate and $todate.

I need to find all the dates for that range to check against a database table. So for example, I have $fromdate 26/9/2005 and $todate 4/10/2005, I need to get all the dates inbetween those two (I have put them in UK format dd/mm/yyyy in case anyone wonders).

How would I do this? I know that I want to hold them in an array to do the check afterwards, but am not too sure how to go about it in the first place.

Thanks

Richard
 
Can't you just use the database to do it for you?

SELECT field FROM table WHERE thisdate>=$fromdate and thisdate <= $todate

OR,

SELECT field FROM table WHERE thisdate between $fromdate and $todate

??
 
Thanks all,

Couldn't do it from the database as it the dates are held in three fields (year, month and day) so it is obviously quite difficult to check like that.

In the end, I found another thread in the forum that sorted me out.

For anyone else that want to have a look, here it is:


Works a treat (although I had to change it a bit to suit UK dates etc.)

Rich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top