This one time, at band camp, Kevin Waterson <[EMAIL PROTECTED]> wrote:

>  seasonDateFrom           seasonDateTo          seasonRateWeekly
>  2004-06-02 00:00:00    2004-10-31 00:00:00     42.86
>  2004-01-01 00:00:00    2004-06-01 00:00:00     34.29
> 
> When I take a booking I have yet another range
> $bookingDateFrom and $BookingDateTo
> 
> I need to get the SUM(seasonRateWeekly) for each day in the booking range.

Thanks for the help guys, here is the solution I came up with so far...
I think I need to break down process into

1) get the seasons
2) get the number of days used in each season
3) multiply the season rate my the number days used in each season

Sounds alot easier when put that way... so firstly I n
step 1 I can do with a query like 
SELECT * FROM seasons WHERE (booking_begin_date BETWEEN seasonDateFrom AND 
seasonDateTo)
OR (booking_end_date BETWEEN seasonDateFrom AND seasonDateTo)
OR (booking_begin_date <= seasonDateFrom AND booking_end_date >= seasonDateTo)

This works well. Now, step 2...
How can I get the number of days used in each season?

Kind regards
Kevin

-- 
 ______                              
(_____ \                             
 _____) )  ____   ____   ____   ____ 
|  ____/  / _  ) / _  | / ___) / _  )
| |      ( (/ / ( ( | |( (___ ( (/ / 
|_|       \____) \_||_| \____) \____)
Kevin Waterson
Port Macquarie, Australia

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to