Skip to main content
kenneth kam chuh21426993
Known Participant
Jan 9, 2025 2:00 AM UTC
Question

How to assign an expiry date based on the earliest date of the three date fields

I have 3 reagents with different expiry dates and I need to assign the earliest expiry date among the 3 for the final product.  I am using Acrobat Pro and any help is greatly appreciated.  Thanks!

Below is the image of the Date fields of the three reagents 

 

Below is the text field of the expiry of my final product

 

 

2 replies

Nesa Nurani
Community Expert
Community Expert
Jan 9, 2025 6:15 AM UTC

Use this as custom calculation script of "ProductExpiry" field:

var d1 = this.getField("GelExpDate_af_date").valueAsString;
var d2 = this.getField("WFIExpDate_af_date").valueAsString;
var d3 = this.getField("N2ExpDate_af_date").valueAsString;

if(d1 == "" || d2 == "" || d3 == "")
 event.value = "";
else{
 d1 = util.scand("dd/mm/yyyy", d1);
 d2 = util.scand("dd/mm/yyyy", d2);
 d3 = util.scand("dd/mm/yyyy", d3);

var earliestDate = new Date(Math.min(d1, d2, d3));

event.value = util.printd("dd/mm/yyyy", earliestDate);}
Translate
kenneth kam chuh21426993
Known Participant
Jan 12, 2025 10:13 PM UTC

Thanks heaps for your help. You've always been helpful. Greatly appreciated. 

Translate