End Date Calculation based on a user entered Start Date and Number of Days | Community
Skip to main content
nowackem
Level 5
March 29, 2022
Solved

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

  • March 29, 2022
  • 1 reply
  • 1225 views

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.google.com/file/d/1hVW7-znksC6T7U23-G2pq8TMC3AUq_0l/view?usp=sharing

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by MHWinter

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) 
}

1 reply

MHWinter
MHWinterAccepted solution
Level 4
March 30, 2022

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) 
}
nowackem
nowackemAuthor
Level 5
March 30, 2022

Perfect! thank you so much!!