News for hackers. Stuff that matters.
Re:Lesser-known Postgres features by micw on Tuesday November 09, 2021 @02:31PM (#29166301)
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.

Re:Lesser-known Postgres features by KarlKemp on Tuesday November 09, 2021 @05:13PM (#29168220)
I 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.

Re:Lesser-known Postgres features by zeroimpl on Tuesday November 09, 2021 @09:09PM (#29170311)
Don’t you just treat the range as half-open? Eg a '[)' range in Postgres.
Re:Lesser-known Postgres features by rvdginste on Wednesday November 10, 2021 @12:45AM (#29171482)
If 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.

Re:Lesser-known Postgres features by micw on Tuesday November 09, 2021 @02:50PM (#29166560)
I 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;

Re:Lesser-known Postgres features by jpitz on Tuesday November 09, 2021 @02:36PM (#29166361)
Well, for this feature, it means if meeting a and meeting b share any point in time ( except their boundaries )
Re:Lesser-known Postgres features by micw on Tuesday November 09, 2021 @02:42PM (#29166450)
I have tried this with the condition I described and does not see any where it fails.
Re:Lesser-known Postgres features by jayd16 on Tuesday November 09, 2021 @02:38PM (#29166386)
You'd fail on the exactly the same time case.
Re:Lesser-known Postgres features by grangerg on Tuesday November 09, 2021 @08:58PM (#29170244)
Both 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.