Skip to main content
yanksgirl
Inspiring
March 5, 2026
Question

Display DD with suffix (nd,rd,th) using mapped MM/DD/YYYY field

  • March 5, 2026
  • 1 reply
  • 7 views

I have a form that automatically maps a Loan payment due date as MM/DD/YYYY.  There is another field (we’ll call that field LOAN_DAY) on the form that requires that DD field, but my core system doesn’t have it as a mappable field so I’m trying to figure out not only how to extract it from the loan payment due date field (we’ll call that field LOAN_PAYMENT) but also how to add the suffix (i.e. DD = 20 but needs to become 20th).

I’ve played around with extracting the DD to a separate field and then trying to build a validation in the LOAN_DAY to add that suffix but I’m just completely stumped.  I haven’t found anything similar asked in this forum so hoping someone can help!

Example: mapped field LOAN_PAYMENT = 03/20/2026.  unmappable field LOAN_DAY needs to show 20th.

 

Thank you all in adavance!

    1 reply

    try67
    Community Expert
    Community Expert
    March 5, 2026

    Use this code as the custom Calculation script of LOAD_DAY:

     

    var v = this.getField("LOAN_PAYMENT").valueAsString;
    if (v=="") event.value = "";
    else {
    var d = util.scand("mm/dd/yyyy", v);
    event.value = formatOrdinalDay(d);
    }

    function formatOrdinalDay(d) {
    if (d==null) return "";
    if (d.getDate()==11 || d.getDate()==12 || d.getDate()==13)
    return d.getDate()+"th";
    else if ((d.getDate()%10==1)) return d.getDate()+"st";
    else if ((d.getDate()%10==2)) return d.getDate()+"nd";
    else if ((d.getDate()%10==3)) return d.getDate()+"rd";
    else return d.getDate()+"th";
    }