How to search for overlapping time slices?

Muhammad Kaleem asked on October 20, 2019 10:50

I have a list of objects, there are multiple objects in list and every object contain StartTime and EndTime, for example:

StartTime: 09:00 EndTime: 10:00

StartTime: 09:30 EndTime: 10:15

StartTime: 10:00 EndTime: 10:30

StartTime: 11:00 EndTime: 11:30

StartTime: 11:45 EndTime: 13:00

StartTime: 12:45 EndTime: 14:00

In the above example there are three groups of time intervals with and without overlapping:

1) StartTime: 09:00 EndTime: 10:30

2) StartTime: 11:00 EndTime: 11:30

3) StartTime: 11:45 EndTime: 14:00

Please suggest how can I modify my query to get the results like above example, any help will be highly appreciated.

Recent Answers


David te Kloese answered on October 21, 2019 09:55 (last edited on October 21, 2019 09:55)

Hi, not really specific for Kentico. You might be able to get more help on Stack Overflow.

But a quick Google search got me to when you get the data from SQL: http://www.kodyaz.com/t-sql/sql-query-for-overlapping-time-periods-on-sql-server.aspx

Which might be something you're looking for.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.