That's about what I thought, so try this as the time out formula
=INDEX(MOD('Data exported from acces sistem'!$I$2:$I$20,1),
MATCH(1,('Data exported from acces sistem'!$G$2:$G$20=$A3)
*((INT('Data exported from acces sistem'!$I$2:$I$20)=$B$1)+(INT('Data exported from acces sistem'!$I$2:$I$20)=$B$1+1)),0))
(I see you already cater for the midnight overlap in your totals formula).
Bookmarks