I have been trying to do a date calculation in my form and cannot seem to get it to work. I have searched through the forums and have found what seemed to be solutions, however, they also have not worked. I can't seem to get the scripts that I've found to function and believe that maybe I am not referencing my fields in livecycle correctly. The following script is directly from this link:
http://www.acrobatusers.com/tech_corner … ime_part1/
var strEnd = this.getField("DateEnd1").value;
if(strStart.length && strEnd.length)
{
var dateStart = util.scand("mmm d, yyyy",strStart);
var dateEnd = util.scand("mmm d, yyyy",strEnd);
var diff = dateEnd.getTime() - dateStart.getTime();
var oneDay = 24 * 60 * 60 * 1000;
var days = Math.floor(diff/oneDay);
event.value = days;
}
else
event.value = 0;
This is exactly what I'm trying to do but don't know where I am going wrong.
My fields are date/time fields and the calculation I am trying to do is:
CessionTo - CessionFrom = No. of Days
Can anyone help?
Thanks in advance!
If you carefully read the how to article it is for using Acrobat JavaScript and the form is an Acro From not a LiveCycle Designer form. One can not just cut and past Acro Forms JaavaScirpt inot LiveCuycle Designer.
LiveCycle Designer has a number of functions available to FormCalc. You can use the "Date2Num()" function to get the number of day since the Epoch date for a given date string and matching format string.
Have you loooked at [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=13175]Date Subtraction Live Cycle continued[/url]?
You will have to adjust the field names and format strings to match your particular situtation.
George Kaiser