Expiration Date Chart with Javascript
Hello! I am creating an expiration date chart that has a date formatted field named “event_date”, and four other read only fields that will display a date in the future based on the event date: 7 Days, 30 Days, 12 Weeks, and 6 Months
I have scripted out 2 years’ worth of dates like this (an example for 7 days in the future):
var v = this.getField("event_date").valueAsString;
if (v=="") event.value = "";
else {
if (v=="01/01/2023") event.value = "01/08/2023";
else if (v=="01/02/2023") event.value = "01/09/2023";
else if (v=="01/03/2023") event.value = "01/10/2023";
else if (v=="01/04/2023") event.value = "01/11/2023";
This works, but as you can imagine, this is labor intensive, and will need to be manually updated every 2 years. Can this be done with javascript, so that the dates work, including accounting for leap years, and do not need to be updated periodically?
Note: For expiration dates that are in months which have fewer days than the event date month, could we force the expiration date to be the last date in the expiration month? Here’s a 6 month example:
Event Date Expiration Date
8/28/23 2/28/2023
8/29/23 2/28/2023
8/30/23 2/28/2023
8/31/23 2/28/2023
Thank you!
