Skip to content Skip to sidebar Skip to footer

Converting Excel Formula To Javascript Code

I was trying to get the Months in period , rent in period and monthly rent and the remaining obligation which is the total based on the formula/ using the excel formula below , I h

Solution 1:

Your Days360 implementation is not working properly. The following code is tested to behave the same way as Excell DAYS360:

function Days360(start: Date, end: Date, decimalPlace: number = 2){
    if(!start || !end) return undefined;
    const days = (end.getUTCFullYear() - start.getUTCFullYear()) * 360
        + (end.getUTCMonth() - start.getUTCMonth()) * 30
        + (end.getUTCDate() - start.getUTCDate());
    return parseFloat(parseFloat(days.toString()).toFixed(decimalPlace));
}

Post a Comment for "Converting Excel Formula To Javascript Code"