I am creating a form for work and I already created two Date/Time Fields and I want a third field to automatically calculate the difference between the two dates in days. I then need to use this result in another equation. It goes as follows (for example):
Settlement Date (SD): 06/19/2019
Maturity Date (MD): 06/25/2019
Discount Rate (DR): 17.50%
Number of Days (ND): 6
First I need to calculate the number of dates and let it populate one of the fields in the form, so I need to let the form subtract whatever date is in SD from MD and give me the result in days.
Second, I need to use the result in days in the following equation
or an equation that would directly go as =(1/(((MD-SD)/365)*(RD/100)+1))
I have no experience in Java and I am using LiveCycle Designer the comes with Adobe Professional 7
I use Windows 10 as an OS
I would really appreciate all the accurate help I can get. I am lost …. THANK YOU !!!!!!!!!!!
var sd = new Date(SD.rawValue);
var md = new Date(MD.rawValue);
Math.round((md.getTime() - sd.getTime())/(1000*60*60*24));
This assumes that your two date fields are called SD and MD, so you may have to change those. I'm not sure were you need to put the code, if you are displaying the number of days in a field then put it in the calculate event of that field. If it is only for the use in the expression then assign the result to another variable and use that, so;
var nd = Math.round((md.getTime() - sd.getTime())/(1000*60*60*24));
The "1000*60*60*24" is the number of milliseconds in a day, so if you want you could calculate that as its fixed.
If any of you users have older versions of Reader then replace the "new Date(SD.rawValue)" part with "
util.scand('yyyy-mm-dd', SD.rawValue) and the same on the next line.