# Calculate the occupancy rate

Hi bubblers,

Today I try to create statistics on my dashboard to calculate the occupancy rate of my accommodations.

I have a database that contains all the reservations made with information by column such as: “booking_start”, “booking_end”, “number_of_night”, “rental_id”

I would like to calculate the occupancy rate of my accommodations over a given period, for example: from March 1st to March 31st.

The problem is that I don’t know how to compare the nights so as not to take into consideration a reservation having for example started on February 15 and ending on March 15.

In fact, the length of stay is therefore approximately 30 days. But would you have a calculation or a solution to use to count only the 15 days of the month of March? Maybe a plugin?

Hi, no plugins or advanced calculations required.
In my opinion, you should not consider the month, just work with the date itself.
To solve this problem, you can divide accommodations into 3 types:

1. Start before the given period
2. Start and end within the given period
3. End after the given period

Is this clue enough to get you started?
If you have any questions, tell me and I will explain more.

Tank you @NoCodeDataArtisan

I understand what you mean. However in the search filter let’s assume it includes bookings that start before the given time period so this will fail the result?

Sorry for my very late response, I have been working on another project in the meantime which I have just completed. I would have liked to provide access to the editor, but it is already a finished version and I don’t think the boss will agree.

In the solution provided earlier, I understood the initial idea for isolating the different types, but I don’t see how to proceed afterwards. The result will definitely be incorrect for accommodations that have reservations straddling two months.

1 Like

Hey there

Don’t worry about the late. I hope the other project has been successful.

Actually, I totally forgot about the idea behind my suggestion

After the challenge you raised, we provided a plugin to work with all kinds of lists and put many operations that cannot be implemented in the bubble or with difficulty. There is an element in plugin specifically for date time data list that can solve your problem. I can send you the link if you want.