Expand my Community achievements bar.

SOLVED

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

Avatar

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!!

https://drive.google.com/drive/folders/1EASnF9uPd6PP69_SgfwuPojJJuZOBd-L?usp=sharinghttps://drive.go...

 

1 Accepted Solution

Avatar

Correct answer by
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) 
}

View solution in original post

4 Replies

Avatar

Correct answer by
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) 
}