Copy link to clipboard
Copied
I have four fields on a form:
"StartDate", "EndDate", "EvalDate", (all formatted as: "yyyy mmm dd") and also "PercElapsed" (formatted as a percentage with one decimal place). The time difference between "EndDate" and "StartDate" is the total period, or duration, of an event. "EvalDate" is a date between the Start and End dates. "PerElapsed" returns the value representing the time elapsed on the day of "EvalDate" since the day of "StartDate" (as a percent of the total period). The "EndDate" field is a future date automatically calculated depending upon the entry in "StartDate" and a multiplier (representing months) selected from a Drop Down (i.e.: if "StartDate" is today and multiplier selected is "12" then "EndDate" returns a future date exactly 12 months from today - and works very well!.) The "EndDate" and "PerElapsed" fields have been set as Read-Only.
My dilemma: writing the code to correctly calculate this percentage: ("EvalDate"-"StartDate")/("EndDate"-"StartDate"). Seems easy enough, but this has busted my chops.....
THANK YOU kindly for all assistance!!
You need to convert the values of all the fields to Date objects, using the util.scand method.
Then get the pure numeric values of all of these Dates by accessing their getTime method.
Then perform your calculations and write back the result to the event.value property of the calculated field.
Copy link to clipboard
Copied
You need to convert the values of all the fields to Date objects, using the util.scand method.
Then get the pure numeric values of all of these Dates by accessing their getTime method.
Then perform your calculations and write back the result to the event.value property of the calculated field.
Copy link to clipboard
Copied
Thank you!! Works beautifully!