calculate duration between intervals of 15 minute
3 Step approach:


generate the intervals.
match calls against overlapping ranges
figure the duration of each call within that range



create table #calls 
(id int not null identity primary key, 
starttime datetime, 
duration int)

insert into #calls (starttime, duration) values 
('2018-05-14 8:33:00', 45) -- 1 period
,('2018-05-14 8:42:00', 460) -- 2 periods
,('2018-05-14 8:55:00', 3500) -- 5 periods

--Assume table [Number] (N int) with rows 1 to 1 mil. 
;
with Intervals as 
(select top (150000) dateadd(mi, n*15, '2018-01-01') interval_start, 
dateadd(mi, n*15+15, '2018-01-01') interval_end 
from Number order by N)
select * , 

case
--Full 15 min 
when starttime &lt;= interval_start and dateadd(ss, duration, c.starttime) &gt;=  interval_end 
then 15*60
-- partial, overlapping start
when starttime &lt;= interval_start and dateadd(ss, duration, c.starttime) &lt;  interval_end 
then datediff(ss, interval_start, dateadd(ss, duration, c.starttime))
-- partial, overlapping end
when starttime &gt; interval_start and dateadd(ss, duration, c.starttime) &gt;= interval_end 
then datediff(ss, c.starttime, interval_end)
-- partial, wholly contained
when starttime &gt; interval_start and dateadd(ss, duration, c.starttime) &lt; interval_end 
then duration
else null
end  interval_duration

from #calls c inner join Intervals 
on dateadd(ss, duration, c.starttime) &gt;= interval_start 
and c.starttime &lt; interval_end


go

drop table #calls