Below is a PostgreSQL example how to get the average response time for the first quarter in a way that non-working hours and weekends are not included.
If the request came at 17:02, it is calculated as it came the day after at 8:00.
SELECT avg((SELECT sum(case when dif<‘0:00’::time then dif+interval ‘8 hour’ else dif end)
FROM ( SELECT i::time-lag(i,1) over (order by i)::time as dif
FROM generate_series(received, accepted, interval ‘1 minute’) i
WHERE date_part(‘dow’, i) not in (0, 6)
and i::time between ’08:00′ and ’16:00′
WHERE priority=’High’ and extract (quarter from received)=1