Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating Dates

Status
Not open for further replies.

strtech

Technical User
Oct 30, 2006
27
US
I am trying to subtract two date fields that I thought would be very easy. I'm creating a form in Adobe Acrobat. However, I am either coming up with a blank field or the "NaN" message and I don't know why.

Both of my fields are formatted as a date field. My calculation field is formatted as a general field. I have searched the internet and am still coming up short.

Here is my code:

var b=getField("901d").value;
var e=getField("901e").value
var Begdate=new Date(b);
var Enddate=new Date(e);
var difference=(Begdate-Enddate)/86400000;
event.value=difference + " days";


Can anyone see the problem?

Thanks in advance.
 
I don't think the form reference is omnipresence. Maybe you should add the reference this?
[tt] var b=[red]this.[/red]getField("901d").value;
var e=[red]this.[/red]getField("901e").value
[/tt]
 
The second thing to check is whether your function getField() is returning a string or a number. The date() constructor will accept either one, but does different things depending on which type its argument is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top