You are here:

# Excel/Pro-rated according date difference

Question
QUESTION: Hi, i have been asking around this question in forum, however, no one is able to answer. Hope you are able to help.

My company is dealing with domitory and hence we billed our customer Rental every month. Lets say, Company name is at A2, Rental Rate per month B2, C2 will be the date where the company start staying, D2 will be the date where the company leave.

For example, monthly rental is \$1000. If the company start from 01/01/2012-31/03/2012. The total rental will be \$1000 x 3= \$3000. However, if the company stay from 15/01/2012-31/03/2012, the rental will be 17/31*\$1000 (Jan's rental) + \$2000 (Rental for Feb n March). If stay from 01/01/2012-15/03/2012. It will be \$2000 (Rental for Jan & Feb) + \$1000*17/31 (Rental March).

Its easy to manually calculate the total rental we collect from 1 company. However, we have 200+ of companies and each check in check out at different period.

My idea is to have a "FROM DATE" and "TO DATE", in maybe Cell A1 n B1. Then from there, the rental we collected from individual companies will show.

Is it possible to email you my excel file? Its easilier to explain that way.

Not too difficult.

I have this setup:

Cell     Value/formula
B2       1000          (the rent)
C2       16-nov-2012    (starting date)
D2       1-Feb-2013     (ending date)
E2       =DATEDIF(C2,D2,"m")   (Number of whole months)
F2       =DATEDIF(C2,D2,"md")  (Number of remaining days after subtracting entire months)
G2       =(DATE(YEAR(C2),MONTH(C2)+1,0)-DATE(YEAR(C2),MONTH(C2),1))+1  (number of days in month of cell C2)
H2       =(DATE(YEAR(D2),MONTH(D2)+1,0)-DATE(YEAR(D2),MONTH(D2),1))+1  (number of days in month of cell D2)
I2       =F2/IF(DAY(C2)=1,G2,H2)  (Fraction of month. Assuming only one month was partly "used")
J2       =B2*I2+B2*E2   (Rent to be paid)

---------- FOLLOW-UP ----------

QUESTION: Hi, i tried inputting all your data a testing excel sheet. But the result aint exactly what i want. Maybe you misunderstand my question, thats why i really hope i could send you a sample file through email.

Using your formula, the starting n ending date you given, the result (Cell J2) shows 2071.429 which is incorrect. From 16/11/2012-01/02/2013, a monthly rate of \$1000 should give me

16/30*1000 (Rental Nov) + 1000 (Rental Dec) + 1000 (Rental Jan) + 1/28*1000 (Rental Feb) which is \$2569.048. Morever, i replace 01/02/2013 with 17/11/2012. The result shows 0, by right, it should show a 1/30* 1000.

Please allow me to send you a sample excel. I really need some help with this, I had even ask my IT department guys but none is able to give me an answer, however, all of them say its absolute possible and can be done. Just that its not easy.

I have changed the approach slightly and I expect this will work for your situation.

B2 1000 (the rent)
C2 16-nov-2012 (starting date)
D2 1-Feb-2013 (ending date)
E2 =DATEDIF(C2,D2,"m") (Number of whole months)
F2 =IF(C2=DATE(YEAR(C2),MONTH(C2),1),0,1)+C2-DATE(YEAR(C2),MONTH(C2),1) (Number of rental days in first month, if start date is first of month, this returns zero)
G2 =IF(D2=DATE(YEAR(D2),MONTH(D2)+1,0),0,D2-DATE(YEAR(D2),MONTH(D2),1)+1) (number of rental days in last month, equals zero if last date is on last day of month)
H2 =(DATE(YEAR(C2),MONTH(C2)+1,0)-DATE(YEAR(C2),MONTH(C2),1))+1 (number of days in month of cell D2)
I2 =(DATE(YEAR(D2),MONTH(D2)+1,0)-DATE(YEAR(D2),MONTH(D2),1))+1 (number of days in last month)
J2 =B2*E2+B2*F2/H2+B2*G2/I2 (rent to be paid)

This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

#### Jan Karel Pieterse

##### Expertise

Excel and Excel/VBA questions

##### Experience

Excel MVP

Organizations
Self employed Excel developer

Education/Credentials
Bachelor in Chemical Engineering

Awards and Honors
Microsoft MVP award since 2002

Past/Present Clients
Shell, Fortis bank, ABN-AMRO bank, Morgan Stanley, ...