Date range intersection in SQL

Posted by Will on Stack Overflow See other posts from Stack Overflow or by Will
Published on 2010-05-05T07:25:38Z Indexed on 2010/05/05 7:28 UTC
Read the original article Hit count: 336

Filed under:
|
|

I have a table where each row has a start and stop date-time. These can be arbitrarily short or long spans.

I want to query the sum duration of the intersection of all rows with two start and stop date-times.

How can you do this in MySQL?

Or do you have to select the rows that intersect the query start and stop times, then calculate the actual overlap of each row and sum it client-side?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql