Would someone be kind enough to show me how to correctly write this formula to show hours worked before 8am + hours worked after 5pm

=IF(D6>=0.333333333,0,if(D6-.333333333*24(E6<=0.708333,0, if(E6-0.708333*24))))

D6 is start time and E6 is finish time. Cell m6 hold this formula. My first formula (E6<=0.708333,0, if(E6-0.708333*24 was working fine calculating hours worked after 5pm, then i realized it was not calculating hours before 8am as overtime.