• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Calculate Date on a Form

New Here ,
Jan 28, 2025 Jan 28, 2025

Copy link to clipboard

Copied

I know this question has been asked many times. I have followed so many scripts and I keep running into the same issue and cannot figure out why.

 

I have a date field that will be user entered. I need a 2nd field to calcuate 14 days from that date.

 

The issue that I am having is when i add the script (any that I have tired) the 2nd field calculates 14 days from TODAY. even when I enter a new date in the User entered date field the calculate field will not change. 

 

Very frustrating! (Note I am Not a coder this is new to me... pls be kind) I hope someone can help!

Screenshot 2025-01-28 at 12.02.43 PM.pngScreenshot 2025-01-28 at 11.48.17 AM.pngScreenshot 2025-01-28 at 12.02.54 PM.pngScreenshot 2025-01-28 at 12.03.13 PM.png

TOPICS
PDF forms

Views

46

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
community guidelines
Community Expert ,
Jan 28, 2025 Jan 28, 2025

Copy link to clipboard

Copied

Which field is your script in and what type of script (calculation/validation)?

Votes

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
community guidelines
Community Expert ,
Jan 28, 2025 Jan 28, 2025

Copy link to clipboard

Copied

Check that field is not empty before setting date:

var f = this.getField("NewLatestShippingDate").valueAsString;
var d = util.scand("dd/mm/yyyy", f);

if(f !== ""){
 d.setDate(d.getDate()+14);
 event.value = util.printd("dd/mm/yyyy", d);}
else
 event.value = "";

Votes

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
community guidelines
New Here ,
Jan 28, 2025 Jan 28, 2025

Copy link to clipboard

Copied

LATEST

Ok so idk what i did but ultimately got it to work! this was the code i used in case it can help anyone... 

Thank you everyone who tried to help!!

 

var d = util.scand("dd/mm/yy", this.getField("NewLatestShippingDate").valueAsString);

var theTime = d.getTime () ; var oneDay = theTime + 14*24*3600*1000;

var dd = new Date(oneDay); event.value = util.printd("dd/mm/yy", dd)

Votes

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
community guidelines