For your cell C4 the formula is
Excel Formula:
=F4/((IF(H4<E4,I4,0)+IF(J4<E4,K4,0)-IF(L4<H4,M4,0))*G4)
You see: it is easier to first add (and substract) each of the quantities based on the dates, and only then do the multiplication and division.
You could also have added an extra cell at the end (N4) called Qty Change with the formula
Excel Formula:
=IF(H4<E4,I4,0)+IF(J4<E4,K4,0)-IF(L4<H4,M4,0)
and then refer to that in C4 with
I don't understand your comment about Q2 calculation. Try to explain it in another way