0

Adding Months to a date

Wondering how to add months to a specified date.  We are managing loans and leases and it would be nice to add say 36 months to an origination date.

5 replies

null
    • Sebastien
    • 4 yrs ago
    • Reported - view

    let theYear := year(Date);
    let theMonth := month(Date);
    let theDay := day(Date);
    let addMonths := 36;
    let newDate := date(theYear, theMonth + addMonths, theDay);

    "Carefull for the end of febuary tough";
    newDate

    • Nick
    • 4 yrs ago
    • Reported - view

    One simpler approach:

    Fields:

    - Date (date)

    - Number of Months (number)

    and the formula:

     

    date(year(Date), month(Date) + number('Number of Months'), day(Date))

    • Sebastien
    • 4 yrs ago
    • Reported - view

    If it's a pair number like 36, there is no problem except if the start date is over day 28 and it lends in febuary. That is because month() are caculated in 31 days. Let say you add 39 months to the 2020/01/31 you are going to get 2023/04/01 and that is 40 months. In the case of loans and leases management that could potentially be a problem. So be carefull with a simple approach.

    • Nick
    • 4 yrs ago
    • Reported - view

    Both codes produce the same result. I just meant that in this case you don't need the variables.

    • Sebastien
    • 4 yrs ago
    • Reported - view

    If you want to get accurate about the end dates of any months, try this simple formula contaning at least one variable:

    let overDate := date(year(Date), month(Date), 31);
    if month(overDate) > month(Date) then
    overDate - day(overDate)
    else
    overDate
    end

    Then if you want to make accurate projections over many months, you will need more variables and a loop.

Content aside

  • 4 yrs agoLast active
  • 5Replies
  • 1234Views