dfrojd Posted March 20, 2008 Share Posted March 20, 2008 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) Quote Link to comment Share on other sites More sharing options...
MatthewJ Posted March 20, 2008 Share Posted March 20, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.