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

Calculating days left in the month from a given date

New Here ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

I'm creating a fillable form for a customer who is trying to track "eligible" days in a given month. This is hospital related information, so the client wants to be able to have a field where they enter a date, example 04/02/2020 (date of admission) and then have a field at the bottom that automatically calculates the number of days left in the month (eligible days), as those admitted to this facility will receive this particular coverage until the end of the month. The date of admission also counts as an eligible date.  I've tried a few codes, but everything that I know to do requires you to enter an "end date" so to speak and then calculates the days between. Is there something that will allow the field to pick up the month that's entered into the admission date field and then calculate the number of days left for that particular month...similar to how Excel works? The only other thing I know to do is to create an extra field so the last day of the month can be entered and then have the code in the Eligible Days field to calculate the difference +1 (to account for the day of admission).

 

Thanks in advance. 

TOPICS
Acrobat SDK and JavaScript

Views

338

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 ,
Apr 14, 2020 Apr 14, 2020

Copy link to clipboard

Copied

LATEST

Do you know how to work with the Date object in JavaScript? If so, you can take the admission date, add one month to it, change the day to 1, and then calculate the difference between the original date and that one. It will give you the result you want.

If you are not familiar with this object, these tutorials are a good place to start learning about it:

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript
https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-2
https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3

 

Edit: Date object, of course, not Data...

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