Highlighted

add days to a date

New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

I am trying to add 10 days to a date which a user enters into a form. I have created a date field "Date1", I have created a Date field "Date2". In the Calculate tab , under Custom Script, i placed the following code

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

}

It does not work (I took this code from a previous post)
I have tried simple calculated fields like adding two numbers together, and i can get that to work

TOPICS
PDF forms

Views

41

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 days to a date

New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

I am trying to add 10 days to a date which a user enters into a form. I have created a date field "Date1", I have created a Date field "Date2". In the Calculate tab , under Custom Script, i placed the following code

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

}

It does not work (I took this code from a previous post)
I have tried simple calculated fields like adding two numbers together, and i can get that to work

TOPICS
PDF forms

Views

42

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
Oct 24, 2020 0
Engaged ,
Oct 24, 2020

Copy link to clipboard

Copied

Did you format fields as dd/mm/yyyy ?

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...
Oct 24, 2020 0
New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

I had changed it, sorry did not update the post, I did mm/dd/yy

Get Outlook for iOS

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...
Oct 24, 2020 0
Most Valuable Participant ,
Oct 24, 2020

Copy link to clipboard

Copied

Change +30 to +10... Also, check the JS Console for errors.

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...
Oct 24, 2020 0
New Here ,
Oct 24, 2020

Copy link to clipboard

Copied

Got it, thank you, my error was inconsistant formatting between the two fields

 

 

 

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...
Oct 24, 2020 0