Skip to main content
Participant
May 8, 2018
解決済み

add 30 days from the date stamp

  • May 8, 2018
  • 返信数 2.
  • 10137 ビュー

Hello,

can you please help me? I have a form which I send to customers. The first field the will do is select the date they are working on the form... (I still have to figure out how to name the tab so the customer can see the tab name as date), anyways, what I need to happen next is to have my last tab on the bottom auto add 30 days from the date selected by the customer on top.

Example

Customer opens the PDF, and selects the date as 1 may 2018, base of that the form will automatically calculate and add the 30 days as 31 May 2018

This investigation must be completed no later than 31 May 2018. (The 31 May 2018 is auto completed and can not be changed, it will basically inform the customer that that is his/her due date).

Can you please help?

Thank you

HanzCzech

このトピックへの返信は締め切られました。
解決に役立った回答 try67

You placed the code in the wrong location. It needs to go under the Calculate tab, in the third option ("Custom calculation script").

Also, if your date format is actually "mm/dd/yyyy" (and not "dd/mm/yyyy", which is what I used) then you need to change that in the code, too.

返信数 2

Participating Frequently
August 24, 2023

Hi,

 

Can anyone help as this does not seem to be working properly:  Im using the code but ammended to show days:

var s1 = this.getField("Date1").valueAsString;

if (s1="") event.value = "";

else {

var d1 = util.scand("dddd dd/mm/yyyy", s1);

d1.setDate(d1.getDate()+1);

event.value = util.printd("dddd dd/mm/yyyy", d1);

}

 

This is not pulling from field Date1 though, it is using the current day as input.  Can anyone see what ive done wrong?

 

 

try67
Community Expert
Community Expert
August 24, 2023

Are you sure this is the actual value of the field, and not just a formatted value? What does it show when you click into it?

try67
Community Expert
Community Expert
May 8, 2018

Let's say the fields are called Date1 and Date2 and that the format is "dd/mm/yyyy".

Use this code as the custom calculation script of Date2:

var s1 = this.getField("Date1").valueAsString;

if (s1=="") event.value = "";

else {

    var d1 = util.scand("dd/mm/yyyy", s1);

    d1.setDate(d1.getDate()+30);

    event.value = util.printd("dd/mm/yyyy", d1);

}

hanzCzech作成者
Participant
May 8, 2018

Hello,

thank you. I have just tried that, and it did not work... I am sorry, new with this.

try67
Community Expert
try67Community Expert解決!
Community Expert
May 8, 2018

You placed the code in the wrong location. It needs to go under the Calculate tab, in the third option ("Custom calculation script").

Also, if your date format is actually "mm/dd/yyyy" (and not "dd/mm/yyyy", which is what I used) then you need to change that in the code, too.