Skip to main content
kenneth kam chuh21426993
Known Participant
January 9, 2025
Question

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

  • January 9, 2025
  • 1 reply
  • 269 views

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

 

 

1 reply

Nesa Nurani
Community Expert
Community Expert
January 9, 2025

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);}
kenneth kam chuh21426993
Known Participant
January 12, 2025

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