No announcement yet.

calculate age down to years, mths, days?

  • Filter
  • Time
  • Show
Clear All
new posts

    i am sure many of you deal with the calculation of interest.
    my head is tried of thinking of detailed calculation right now, but if i am not mistaken, the above code can produce an excellent way of calculating interest to pay if interest is paid based on a monthly basis.

    when calculation is based on days that have already passed this is not problem for interest to be calculated.
    but when your schedule to calculate interest is not regular this can be a problem and this program could be used for such means.

    here is an example.

    let's say i owe you money of 1000 and interest is 12 percent a year.
    and i pay you monthly but i also need a way to pay you for some period that is shorter than a month, an example would be if i paid you off before the end of the next month. also lets say i do not have a way to keep track of compounding periods other than one year.
    by using and comparing the both months and days returned in the two routines i can choose the right month and days for calculating interest.

    if my logic is correct, i would compare the first months results with the second month results, if the first figure is equal to the second, use the first results for calculating interest, if the first figure is less than the second figure, use the second results for calculating interest.

    Last edited by Paul Purvis; 23 Apr 2008, 11:59 AM.
    p purvis


      Interest payments are more complicated than just intervals between birthdays because you have to take into consideration two things: The rate that the interest is compounted (if not a simple interest loan), and the point at which payment is posted. A lot of loan institutions assume that the payment is always made according to schedule, so that as a consequence, even if your actual playment varies somewhat from the schedule, the payment terms remain in force (though you may have to pay a late payment fee if you are excessively late on making the payment). Others use the fact that the payments are late to allow the compound interest to accumulate - this is the reason that compound interest loans were created in the first place. Another benefit of compound interest rate loans is that they are mistakenly believed to infer a lower interest rate than similar simple rate loans.

      However, there is a point missed about using two dates to determine the period between by just subtracting one from the other. The better way is to use ABS(date1 - date2) +1. The ABS() ensures that daycount is always positive, regardless of which order the two dates are entered. And the +1 is necessary because the ending date is always inclusive. That is, instead of the day count between March 1 and March 2 being zero (the result of just subtracting the two), you would add one so that the day count between them is 1 day.


        Pardon? ABS(1-2) + 1 = 2