"diff date" and "if"

I did this in the Painless Lab for testing. Just need to change input fields params.tranDate_as_date and params.businessDate_as_date to Scripted Fields doc['tranDate_as_date'].value and doc['businessDate_as_date'].value.

Parameters

{
  "tranDate_as_date": "2021-02-27T19:28:48+00:00",
  "businessDate_as_date": "2021-02-28T09:28:48+00:00"
}

Script

ZonedDateTime tranDate_as_date = ZonedDateTime.parse(params.tranDate_as_date); 
ZonedDateTime businessDate_as_date = ZonedDateTime.parse(params.businessDate_as_date); 

long diff = ChronoUnit.HOURS.between(tranDate_as_date, businessDate_as_date);

if (diff > 23.5) {
    return "Delay";
} else {
    return "On time";
}

Datetime functions in Painless Documentation