Forum Academy Marketplace Showcase Pricing Features

Booking system - how do I block out dates between a start and end date?

We’re writing a Parking Spot booking app because we rent out a parking space on a nightly basis to Airbnb guests in a building where we have a few units.

How can we prevent a user from booking dates that have already been booked?

Right now we are using the calendar module and so there’s a starting date and an ending date that we are gathering from users, but is there a way to get a list of dates in between these two dates – start and end dates? If so that would seem to be one way.

Or another way- is there a way to run a search to see if a newly proposed start date (and end date) falls in between any existing start and end date?

Open to any even more efficient/better ideas… Thanks!

1 Like

Here’s how I would try it…

Create a database typed “booked date” with the following fields:
Start date (type date)
End date (type date)
User (type user)
Status (type text) - you can do upcoming, past…

With every booking, a new “booked date” entry is created (this could also help form a log for you). To see if a date is booked, you’d search for all booked dates that are upcoming and whose start dates are less than your search date AND end dates are greater than your search date. If no dates meet that criteria, the date is not yet booked. This could happen a few ways, either with a simple message that lets the user know or perhaps by changing colors on calendar days (I think this is possible…). You could also try making booked date intervals (from the above condition search) unclickable on the calendar. I haven’t tested this, but it seems like it should work.

4 Likes

Just a thought if the parking spot is in a large lot - when creating this you might not want to show the exact spot that is available on the calendar until someone has completed the booking. Just in case someone just uses your app to check if a spot is open and cheaps out by just parking there without booking it

Hi @coffeeliu43
Have you found any solution to that? i m facing a similar situation, i need to store a list of dates, based on user inputs - checkin - checkout dates.

regards

Same here, let me know if you guys were able to find a fix. Thanks!