79360807

Date: 2025-01-16 08:29:10
Score: 1
Natty:
Report link

Depending on your use case (do you have pre-existing timeslots that can either be booked or not, or is it just a free format booking system) you can either do a database retrieve that only retrieves unbooked slots and let the user select from that, or you can do a retrieve fro mthe database for any overlapping slots and check if that list returns a count of 0.

Retrieve a booking if:

[StartDateTime < $UserPickedValue/EndDateTime and EndDdateTime > $UserPickedValue/StartDateTime]

That way you get any booking that overlaps. Note that I've used > and < here instead of <= and >= to allow a booking that ends at for instance 11:00 and the next one that starts at 11:00 to exist at the same time, even though the start and end technically overlap.

Now check if the list that is returned has a count of 0 (this is more performant than checking if the list is empty) and if it's 0, your user can go ahead and complete their reservation!

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: ElineMendix