Skip to main content
akhtaraz
Participating Frequently
September 7, 2021
Question

Calculating future date by multiplying current date with a number (of days).

  • September 7, 2021
  • 1 reply
  • 1917 views

Hello,

Greatly appreciate any help I can get in writing a formula in Java Script in a form that I created in Adobe DC Pro. I have never done that before. I only know very basics of Adobe, so please make it as simple as possible.

Here is what I need:

I want a field with current date (Field 1), multipied by a number of days (Field 2) and it calculates future date automatically (Field 3).

For example, I want to schedule a follow up in 30, 60, 90 or 180 days from todays date; I fill in today's date in Field 1, then enter number of days that follow up is desired in field 2 and then it automatically calculates the follow up date in Field 3.

Thank you.

This topic has been closed for replies.

1 reply

first.officer
Inspiring
September 7, 2021

Hi akhtaraz,

 

Think the following might be of use;

 

if (this.getField("Field1").value!="") event.value=util.printd("dd/mm/yy",new Date(util.scand("dd/mm/yy",this.getField("Field1").value).getTime()+(1000*3600*24*this.getField("Field2").value)));
else event.value=this.getField("Field1").value;

 

Obviously adjust according to your own field names....script goes in the "Custom Calculation" of Field3, set Field2 to Number format (0 d.p.). - Oh and Field 1 & 3 to the date format you want, might not be "dd/mm/yy".

first.officer
Inspiring
September 7, 2021

....Oh, and I should add....the only reason I managed to get a working script as per earlier, is thanks to the forum experts on here such as; Try67, Nesa Nurani, Berndt, JR Boulay & Thom Parker and alike (apologies to anyone I've missed out/failed to acknowledge!) - their posts and assistance are invaluable in solving issues, and I know that Try67 has a webpage with a plethora of solutions....well worth a look!.

akhtaraz
akhtarazAuthor
Participating Frequently
September 7, 2021

It is a quality of greatness to remember and acknowledge those who have helped you in the past. I surely want to thank all of  them as their knowledge is now trickling down to me.