search

Home  >  Q&A  >  body text

javascript - How to calculate the number of days for borrowing across months? ? ?

Our repayment time is every month, which means that Party A borrows money from May 5th and repays it on June 5th, which is exactly one month, but it can be repaid in advance.

Calculation of early repayment time:

For example: Party A borrows money from May 5th to repays it on May 6th. We calculate that Party A’s borrowing time is 2 days.

Calculation of early repayment interest:
Daily interest = monthly interest (known) / 30
Total borrowing interest = daily interest

[The timestamp above is Y-m-d 23:59:59 every day]

Assumption: monthly interest = 100 yuan

Here comes the problem: If Party A borrows money from May 5th and repays it on June 4th, it stands to reason that the loan will be repaid one day in advance, but there are 31 days in May. When calculating interest, one day's interest is not included in the calculation.

At this time, Party A has borrowed for 31 days, so the calculated interest is 103.23 yuan. If you repay the loan early, the interest will be calculated too much.

This is so painful! ! ! ! ! ! ! ! ! !

仅有的幸福仅有的幸福2758 days ago619

reply all(6)I'll reply

  • 为情所困

    为情所困2017-05-16 13:00:44

    Obviously your loan interest calculation basis is 30/360, that is, 30 days per month and 360 days per year. Then when calculating early repayment interest, you cannot use the actual number of days (time stamp), but still use the 30/360 interest calculation basis to calculate the number of days (such as using the DAYS360 function of Excel), otherwise you will appear The descriptions are inconsistent.

    Supplement:

    The interest calculation basis is industry regulations and generally cannot be changed at will. In addition to the conventional factors, it is also conducive to comparison with the interest rates of other institutions.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:00:44

    Since daily interest = monthly interest (known)/30, why is the borrowing time not calculated based on 30, but calculated based on natural months? This is unreasonable

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:00:44

    Your logic should change

    1. Get the last day of the month, that is, the number of days in the month

    2. Daily interest = monthly interest (known) / number of days in the month

    3. Total borrowing interest = daily interest

      reply
      0
  • 大家讲道理

    大家讲道理2017-05-16 13:00:44

    Use moment.js

    moment('2017-05-05', 'YYYY-MM-DD').add(1, 'months')

    output is :
    2017-06-05

    My understanding of this question is that his core question is ‘correctly determine whether two dates are one month apart’

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-16 13:00:44

    Daily interest = monthly interest (known)/30 This is wrong, right

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:00:44

    You can change your interest calculation method, that is, directly stipulate the daily interest, such as 30,000 or 50,000, etc. I saw that Alipay's borrowing is based on daily interest calculation. The borrowing method can be divided into daily borrowing and monthly borrowing. , if you borrow on a daily basis, the daily interest rate will be higher, if you borrow on a monthly basis, the daily interest rate will be lower,

    If you borrow by day, the interest will be calculated based on the number of days you borrowed it.
    If you borrow by month, the interest will be calculated based on how many months you actually borrowed, and how many days there actually are in these months.
    It’s so simple, you don’t have to worry about what the interest rate is. Divide by 30 days or 31 days, that is, the daily interest is directly determined, and the interest is calculated according to the actual number of days borrowed

    reply
    0
  • Cancelreply