Changing date field color based on difference in month

New Here ,
Mar 01, 2020

Copy link to clipboard

Copied

Hi,

I am creating a checklist with a "From Date" and an "To Date".

I have another field called "Completed Date". How do i script so that the "Completed Date" field will be filled with Red color if the difference between the "Completed Date" and the "To Date" is less than say 5 months.

I tried reading the "Working with Date and Time" guide but its too much for my understanding.

Thank you!!

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

66

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

What's the format of your date fields?

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
xavsg AUTHOR
New Here ,
Mar 02, 2020

Copy link to clipboard

Copied

Hi,

The format is in dd-mmm-yyyy. 

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

OK. However, calculating the difference in months is tricky, as each month has a different length, so you need to clearly described how it should work first.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
xavsg AUTHOR LATEST
New Here ,
Mar 02, 2020

Copy link to clipboard

Copied

Hi. Thanks for trying to help me. I read the same thing about months ... what if I try to calculate in weeks instead. 

 

Here is how I am envisioning the script to work.

 

I have a "Start Date" and "End Date" of an event happening listed in another date fields on the form.

On this checklist that I have is a list of steps that will need to be completed within a certain timeframe before the start date of the event, and some steps to be taken after the event.

1) If the actions completed is more than 8 weeks, then the field will be filled with Green color.

2) If the actions completed is less than 8 weeks, then the field will be filled with Yellow color.

3) If the actions completed is less than 3 weeks, then the field will be filled with Red color.

I have 53 items on this checklist ... and some will be referencing to the End Date of the event.

 

Thank you so much!!

Likes

Translate

Translate

Report

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