Expand my Community achievements bar.

SOLVED

## End Date Calculation based on a user entered Start Date and Number of Days  Level 6

Good Afternoon All, I need a little help with a date calculation. What needs to happen is when the user enters a Start Date (plStartDate) and the number of DAYS the project is expected to run in the Project Length field (numProjectLength) these two fields will calculate an End Date(plEndDate). I also need the End Date to be null/empty until both the Start Date and Project Length have values which takes it from formCalc to JavaScript.

At the following link is a Designer Form that has two subforms. The first one is named Contract Term (subContractTerm), and it demonstrates the working code that I DO have but it calculates by months. The second subform is named Project Length (subProjectLengthDays) and has the same three objects but I need the formula to calculate by days NOT months. Any help is appreciated. Thanks!!

1 Accepted Solution  Level 5

Try this

```if(plStartDate.rawValue!=null && numProjectLength.rawValue!=null){
var d = new Date(plStartDate.rawValue);
var dd = new Date(d.setDate(d.getDate() + numProjectLength.rawValue));
var newDate = new Date(dd.setDate(dd.getDate()+1));
this.rawValue =  (newDate.getMonth() + 1) + "/" + newDate.getDate() + "/" +  newDate.getFullYear()
this(newDate)
}```
4 Replies  Level 5

Try this

```if(plStartDate.rawValue!=null && numProjectLength.rawValue!=null){
var d = new Date(plStartDate.rawValue);
var dd = new Date(d.setDate(d.getDate() + numProjectLength.rawValue));
var newDate = new Date(dd.setDate(dd.getDate()+1));
this.rawValue =  (newDate.getMonth() + 1) + "/" + newDate.getDate() + "/" +  newDate.getFullYear()
this(newDate)
}```  Level 6

Perfect! thank you so much!!  Level 6

@MHWinter Do you know how to account for leap years on this?  Level 6

So sorry. - NVM. It works perfectly. 