date calculation based on double


I am in a bit of a pickle, may just be the hour that Im still up working.. however what i need to achieve is to come to a date based on a double which is the amount of money being collected.

my software charges interest on a loan per month or part thereof. when a loan is processed a due date is calculated based on X number of months (predefined). So a loan drawn up today (2011-12-23) where X = 3 the due date would be 2012-03-23.

if the person whom has obtained the loan cannot pay the loan back by the due date they can make a payment on this loan to extend the due date. If the the interest on this loan is $30.00 per month or part thereof and they make a payment of $30.00 the loan due date is extended by 1 month becoming 2012-04-23, if the person is to pay $60.00 then the loan due date would be extended by 2 months becoming 2012-05-23, and so on.

the above calculation is easily achieved. my issue is when the amount being paid is not equal of the monthly interest. Say the customer only pays $15.00 the due date would need to be recalculated to somewhere in the middle of the 2012-03-23 and 2012-04-23. If the person was to pay $45.00 then the due date would be recalculated to somewhere in the middle of 2012-04-23 and 2012-05-23.

If anyone would be willing to help me that would be great :) thanks guys!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think , I can help you.

Calculate the perday intrest.
like as you said " they make a payment of $30.00 the loan due date is extended by 1 month "

So intrestPerDay  = $30 / no. of days.
Or if you have that value of intrestRate per day.

Then payment made /  intrestPerDay   = increasedDueDays
and hence you can add these days to current due date.

Hope you need the same.
If you need syntax to add dates or for somthing else then let me know.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pawnitAuthor Commented:
Hey there,

Thanks for the help, i did think of that but where i get stuck is how do i work out how many days there are to calculate the date?
I didnt get you correctly...
Are you missing syntax to calculate days from date or
you dont know  how to calculate intrestRatePerDay? (as there are no such specific method)

If you dont know the syntax then let me know I can help you ..
But I guess on logical part even I am stuck as no clear requirement.

pawnitAuthor Commented:
I am having trouble writing the code to work out the interest rate per day. its a bit difficult as there is not a fixed amount of days between two days/dates.

say for instance, the loan is due on the 2011-10-10 and the person holding the loan came in to extend the due date by paying $15.00, to get the due date to the 2011-11-10 the person needs to pay $30.00. however they can only pay $15. Logic would have it that there is 31 days between 2011-10-10 & 2011-11-10 so the person is paying half the $30.00 the date should extend by half of 31 days being 15.5 days. with rounding down you get 15 days so the new due date would be 2011-10-25.
Use the Date.AddDays() method, e.g
        Dim DueDate As Date = "23/12/2011"
        Dim AmountToExtend As Double = 30.0
        Dim PaidAmount As Double = 15.0
        Dim jh = (PaidAmount / AmountToExtend) * 30
        Dim NewDueDate = DueDate.AddDays((PaidAmount / AmountToExtend) * 30)
        Dim InWords = NewDueDate.Day & " " & NewDueDate.Month & " " & NewDueDate.Year

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.