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

Adding variable days to a date

New Here ,
Nov 27, 2022 Nov 27, 2022

Copy link to clipboard

Copied

Hi

I have a form field that has a variable number of days (in one or two digits, eg 28, 35 or 78) I wish to add a these number of  days to the current todays date, and calcualte the future date.

Example 12  add this number to todays date 12/11/2022 (dd/mm/yyyy) = 23/11/2022  (dd/mm/yyyy) 

Is there forms script that can do this?

 

 

TOPICS
PDF forms

Views

1.0K

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 ,
Nov 27, 2022 Nov 27, 2022

Copy link to clipboard

Copied

You want to show the result in another field?

Let's say that field name is "Date" as validation script of field where you enter number of days use this:

if(event.value == "")
this.getField("Date").value = "";
else{
var days = new Date();
days.setDate(days.getDate() +Number(event.value));
this.getField("Date").value = util.printd("dd/mm/yyyy", days);}

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 ,
Nov 27, 2022 Nov 27, 2022

Copy link to clipboard

Copied

Hi Nesa

Thanks for your reply. Do I have to create a new form field? Where do I place your script in the forms field properties dialogue box, under what tab? 

What I am doing is a medication calculator. (see jpeg) And entering the number of loose tablets, unopened boxes, dosage and finaly arriving at a form field that gives the "number of days supply", I thought it would great if the "number of days supply" triggered a last day of meditation with a date in a form field. Many thanks.

Medication Calculator.jpg

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 ,
Nov 27, 2022 Nov 27, 2022

Copy link to clipboard

Copied

Use script under 'Validate' tab of "Number of Days Supply" field, and make field where you want to show date is same name as in script. When asking for help on the forum, it would be really helpful to tell us actual field names or show screenshot of fields while in 'Prepare from' tool.

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 ,
Nov 27, 2022 Nov 27, 2022

Copy link to clipboard

Copied

LATEST

Hi Nesa

It works perfectly. Thanks for all your help. I flatten the form using Foxit print facility and the file is very small, ideal for archiving.TEST FROM 5.jpg

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