5 ms·
I may be wrong, but isn't "overlapping" just "meeting_a.starts_at<meeting_b.ends_at && meeting_a.ends_at>meeting_b.starts_at"? Or in words: There is an overlap
by micw 5y ago
I may be wrong, but isn't "overlapping" just "meeting_a.starts_at<meeting_b.ends_at && meeting_a.ends_at>meeting_b.starts_at"?
Or in words: There is an overlap if meeting A starts before meeting B ends and meeting A ends after meeting B starts.
So the scenario described looks way more complex as it actual seems to be.
- jayd16 5y agoYou'd fail on the exactly the same time case.
- KarlKemp 5y agoI believe it's about the common case of two events sharing a single (infinitely small) point of time: meeting A from 3 to 4, followed by meeting B from 4 to 5. Those two time periods do overlap mathematically, but not physically: they share the common point of "4", even if that point has duration 0. I know the iCal standard goes into this for a bit.
- zeroimpl 5y agoDon’t you just treat the range as half-open? Eg a '[)' range in Postgres.
- jpitz 5y agoWell, for this feature, it means if meeting a and meeting b share any point in time ( except their boundaries )
- micw 5y agoI have tried this with the condition I described and does not see any where it fails.
- micw 5y agoI get the exactly same result with that query as the "overlap" query: SELECT * FROM meetings, new_meetings WHERE new_meetings.starts_at<meetings.ends_at AND new_meetings.ends_at>meetings.starts_at;
- grangerg 5y agoBoth meeting A and B start at 2pm and end at 3pm. After you're done with that corner case, you may find it better to determine if they don't overlap and negate that.
- rvdginste 5y agoIf you use left-inclusive, right-exclusive intervals [), then then the overlap condition is: meeting_a.starts_at <= meeting_b.ends_at && meeting_b.starts_at <= meeting_a.ends_at So, indeed, the scenario as described in the article is more complex than needed.