Skip to content
Advertisement

How to get occupation of a month?

I have a reservation system but now I want to calculate what the occupation of a room in a month is.

But I’m having trouble with getting accurate results because if a reservations start date is at f.e. 28 december and ends on the 3rd of january it will count or 6 days or none at all depending on the query.

It should count just 3 days since only 3 of the 6 days of the reservation are in december

Advertisement

Answer

Your condition in the WHERE clause is wrong because it will reject reservations where start_date and end_date are not both in the same month:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement