## problems in trying to calculate outstanding daily compounding interest if interest change

My problem arises if the interest rate changes within the year

nr date Rate date Rate rate prime +2 Daily interest rate
1 2009/01/01 2009/02/05 15 17 0.000465753
2 2009/02/06 2009/03/24 14 16 0.000438356
3 2009/03/25 2009/05/03 13 15 0.000410959
4 2009/05/04 2009/05/28 12 14 0.000383562
5 2009/05/29 2009/08/13 11 13 0.000356164
6 2009/08/14 2009/12/31 10.5 12.5 0.000342466

I need a formula that will take into account the interest rate changes for those periods , and for the correct interest rate to be computed in my final compounding interest rate calculation.

eg if invoice date is 2009/01/01 and payment date is 2009/05/28 i would require an IF formula to calculate interest within those ranges, inorder to get the correct interest outstanding due,

My interest formula is

(invoice amount)*(#of latedays)*(1+(daily interest rate/100)) = total payment due incl compounding interest

I need an excel formula to take into account the different interest rate changes,