Thanks @lxp. This was easier than expected Here’s what I got:
if (operation == "sort")
return modifieddate;
now = Now();
diff = DateDiff(d, modifieddate, now);
if (diff < 31)
return Format("%1 days", diff);
elseif (diff < 365)
return Format("%1 months", diff / 31);
else
return Format("%1 years", (diff / 365.0 as %.1));