Date range advanced count calculation in TSQL

Posted by cihata87 on Stack Overflow See other posts from Stack Overflow or by cihata87
Published on 2012-10-19T10:47:05Z Indexed on 2012/10/19 11:01 UTC
Read the original article Hit count: 137

Filed under:
|
|

I am working on call center project and I have to calculate the call arrivals at the same time between specific time ranges. I have to write a procedure which has parameters StartTime, EndTime and Interval

For Example:

Start Time: 11:00
End Time: 12:00
Interval: 20 minutes

so program should divide the 1-hour time range into 3 parts and each part should count the arrivals which started and finished in this range OR arrivals which started and haven't finished yet

Should be like this:

11:00 - 11:20 15 calls at the same time(TimePeaks)
11:20 - 11:40 21 calls ...
11:40 - 12:00  8 calls ...

Any suggestions how to calculate them?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about tsql