MySQL Forums
Forum List  »  Newbie

date calculation help needed -->"DAY", "MONTH"
Posted by: Dennis Freud
Date: March 19, 2008 04:42AM

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/night
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...

php boards have given me this advice
->
you could use the MySQL functions "DAY", "MONTH" to calculate whether that day of the month is in between two dates. You'd just have to give the date fields in the table a year (can be arbitrary, but pick a leap-year just-in-case; say 2000).
->

but I do not know how to put this into praxis...
Any help greatly appreciated.

THX
Dennis
(from sunny Tenerife island)

Options: ReplyQuote


Subject
Written By
Posted
date calculation help needed -->"DAY", "MONTH"
March 19, 2008 04:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.