hi everbody,
i am trying to create form that; first field is "value date" and the second field is "maturity date" (this are in date format) and at the end third field will be = "value date" - "maturity date" and i want this third field will be in number format and can be calculate the days difference field1 and field2.
appreciate your kind answer.
thanks and regards
Caci
From the Acrobat JavaScript documentation:
/* Example of date arithmetic. */
/* Create a Date object with a definite date. */
var d1 = util.scand("mm/dd/yy", "4/11/76");
/* Create a date object containing the current date. */
var d2 = new Date();
/* Number of seconds difference. */
var diff = (d2.valueOf() - d1.valueOf()) / 1000;
/* Print some interesting stuff to the console. */
console.println("It has been " + diff + " seconds since 4/11/1976");
console.println("It has been " + diff / 60 + " minutes since 4/11/1976");
console.println("It has been " + (diff / 60) / 60 + " hours since 4/11/1976");
console.println("It has been " +
((diff / 60) / 60) / 24 + " days since 4/11/1976");
console.println("It has been " +
(((diff / 60) / 60) / 24) / 365 + " years since 4/11/1976");
The above code will work in Arcbat Forms and LiveCycle Designer. For your application, you will need to pass the value of the fields and Acrobat Forms and LiveCycle Designer have a different syntax to reference the field and value. Note that the format of the displayed field is needed to generate the date object. JavaScript uses the date value in milliseconds.
LiveCycle Designer can use some built in functions to simplify the task
$.rawValue = Date2Num(maturity_date.formattedValue, "M/D/YYYY") - Date2Num(value_data, "M/D/YYYY")
LiveCycle use days for the result of the conversion to a number.
George Kaiser