Jump to content

calculate price for stay in hotel with seasonal prices...


dfrojd

Recommended Posts

Hi,

 

I am looking for general help here. I dont know how to start at this... maybe someone can point me in the right direction.

 

I need to calculate how many nights of a given time frame (variable dates) lie within certain ranges of times given to calcutate pricing for a hotel which has different prices depending on the season. (fixed dates).

 

So I have this table (MYSQL) which for example says:

 

from  : to      : price

01/01 : 03/31 : 100,-

04/01 : 12/20 : 120,-

12/21 : 12/31 : 160,-

 

How do I tackle (or at least attack) the problem to calculate the price of a stay in this hotel for, lets say Dec. 18th to Jan. 5th???

 

Obviously the dates which fix the pricing do not have/need the attribute (year) as they are always the same (repeat every year)...

 

but I do not know how to put this into praxis...

Any help greatly appreciated.

 

THX

Dennis

(from sunny Tenerife island)

Link to comment
Share on other sites

How about something like...

 

1. Set the dates of the beginning and end of the rate periods as Timestamps

 

2. Create a variable called total or something to that effect

 

3. Loop through the selected dates as timestamps one day at a time checking which of the specific ranges it falls in, then add the correct amount to the total variable each time through the loop.

 

Hope that helps

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.