[thelist] date ranges

Mike D. Johnson mdjohnson at bcbe.org
Thu Jul 7 11:18:46 CDT 2005


I don't understand what you've recommended but I certainly appreciate
your willingness to help.  Let me try to explain my problem better...  

Here is what I have:

ds is an array that has the start and end dates of a reservation:

reservationStartDate  |  reservationEndDate
	7/1/2005  	    | 	7/3/2005
	7/6/2005  	    | 	7/6/2005

What I need is to create a second array (named allDays) that looks like
this:

7/1/2005
7/2/2005
7/3/2005
7/6/2005

It needs to include all reservationStartDates, all reservationEndDates
and all of the days in between those where applicable

I'm using vbScript in a classic ASP page.

Thanks

-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Matt Warden
Sent: Wednesday, July 06, 2005 4:49 PM
To: thelist at lists.evolt.org
Subject: Re: [thelist] date ranges

Mike,

On 7/6/05, Mike D. Johnson <mdjohnson at bcbe.org> wrote:
> I have items that are reserved for certain dates.
> 
> In my database, I have reservationStartDate and reservationEndDate.
How
> do I get an array with all of the days an item is unavailable?
> 
> I need one array with all start dates, all end dates and all days in
> between those two.
> 
> I'm using ASP and an Access DB. The start and end dates in the DB are
> Date/Time values.
> 
> The final goal is to display a table-style calendar with the available
> dates indicated.

I was developing something like this a couple employments ago. I ended
up creating a custom data structure, because I had to be able to
modify the schedule easily and of course an array would require me to
do expensive shifting and such.

Since you are only reading this information, you should be fine with
an array. However, you do not need to include all days within each
range. This would be quite a waste of space. For each day, you would
simply have logic to show something as reserved if the day is within
the range for that something. Somethign along the lines (off the top
of my head, so grain of salt and whatnot):

$dayreservations = Array();
loop over days
{
   // loop over all reservations (probably for 
   // this month or some such restriction)
   foreach ($reservations as $reservation)
   {
      // if current day in range
      if ($day >= $reservation['begindate'] 
            || $day < $reservation['enddate'])
      {
         // append reference to this array to this day
         $dayreservations[$day][] =& $reservation;
      } // end if
   } // end foreach
} // end loop over days

-- 
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 


More information about the thelist mailing list