I'm looking for a way to get all entries from my reservations table to be shown in a calendar.
Now I know that I will have to iterate over all days of the current week and run a database query to select all reservations with dt_from >= start_of_the_week / start_of_the_day
and dt_to <= end_of_the_week / end_of_the_day
.
But that only gives me the reservations that start or end within the week / respectively within the given day.
What I am trying to figure out is: How do I get the reservations which started earlier and/or end after the current day or week?
I have some kind of the following table design
+----+-------------------+---------------------+---------------------+
| ID | NAME | DT_FROM | DT_TO |
+----+-------------------+---------------------+---------------------+
| 1 | Jeff Atwood | 2020-01-06 09:00:00 | 2020-01-16 09:00:00 |
| 2 | Terry Jones | 2020-01-30 09:00:00 | 2020-02-16 09:00:00 |
| 3 | Brian of Nazareth | 2020-02-06 09:00:00 | 2020-03-16 09:00:00 |
+----+-------------------+---------------------+---------------------+
I have been stuck with this for a while now and would appreciate a push into the right direction.
Thank you :)
(dt_from <= end_of_the_week / end_of_the_day) AND (dt_to >= start_of_the_week / start_of_the_day)
.