These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to add days by script

gombear
Registered: Oct 6 2011
Posts: 18
Answered

Hi,
 
I have date field, "EndDate", and want to display on other field with adding 60 days.
Below code doesn't work.
Could someone tell me what is the problem?
Thanks, Gombear
  
var cDate = this.getField("EndDate");
 
var nDate = Date2Num(cDate, "MM/DD/YYYY") + 60;
 
var cDate = Num2Date(nDate, "MM/DD/YYYY");
 
event.value = cDate.value;

gombear
Registered: Oct 6 2011
Posts: 18
Accepted Answer
After enough googling, I found the answer.

In case if someone need it.

var cDate = this.getField("EndDate").value;

var nDate = util.scand("mm/dd/yyyy", cDate);

nDate.setDate(nDate.getDate() + 60);

event.value = util.printd("mm/dd/yyyy", nDate);
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Your original code was written for forms created in LiveCycle, which is why it didn't work in your form, which I assume was created in Acrobat...

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com