Highlighted

add 30 days from the date stamp

Community Beginner ,
May 07, 2018

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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.

Topics

PDF forms, Windows

Views

808

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

add 30 days from the date stamp

Community Beginner ,
May 07, 2018

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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.

Topics

PDF forms, Windows

Views

809

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 07, 2018 1
Most Valuable Participant ,
May 08, 2018

Copy link to clipboard

Copied

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);

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 08, 2018 1
Community Beginner ,
May 08, 2018

Copy link to clipboard

Copied

Hello,

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

Date1.PNG

Date1_format.PNG

Date2.PNG

Date2_format.PNG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 08, 2018 0
Most Valuable Participant ,
May 08, 2018

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 08, 2018 0
Community Beginner ,
May 08, 2018

Copy link to clipboard

Copied

I appreciate you! Thank you very much!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 08, 2018 0
New Here ,
Apr 15, 2020

Copy link to clipboard

Copied

Hello,

I used your Your code also, and it was very useful for me, thank you for this.

I have a question, please see if you can have time to help me.

In your code there is an exact number which is 30. But I put a place in my form (name is "Days") where I can write the number which I need. Then I need to use this fillabele place ("Days") instead of 30 in your code.

 

Thank you in advance.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2020 1
Most Valuable Participant ,
Apr 15, 2020

Copy link to clipboard

Copied

Sure. Just change this line of the code:

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

To this:

d1.setDate(d1.getDate()+Number(this.getField("Days").valueAsString));

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 15, 2020 0
New Here ,
Jun 07, 2020

Copy link to clipboard

Copied

Hello Try67,

 

How will i change the code if i want to add 5 years to Date1.

Sampe is 31/01/2000 on Date1 (dd/mm/yyyy format). 

 

Date2 should have 31/01/2005

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 07, 2020 0
try67 LATEST
Most Valuable Participant ,
Jun 08, 2020

Copy link to clipboard

Copied

Use this:

d1.setFullYear(d1.getFullYear()+5);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 08, 2020 0