Entries
Result
empty(prop("Date")) ? "No Date" : ((formatDate(prop("Date"), "L") == formatDate(now(), "L")) ? "Today" : ((start(prop("Date")) < now() and end(prop("Date")) > now()) ? (format(ceil(dateBetween(end(prop("Date")), now(), "hours") / 24)) + " days left") : ((end(prop("Date")) < now()) ? (format(abs(ceil(dateBetween(end(prop("Date")), now(), "hours") / 24))) + " days ago") : (format(ceil(dateBetween(prop("Date"), now(), "hours") / 24)) + " days away"))))
empty(prop("Date")) ? "No Date"
If
Date
is empty, display No Date
: ((formatDate(prop("Date"), "L") == formatDate(now(), "L")) ? "Today"
Otherwise if the localised
DD/MM/YYYY
format of the start date of Date
is the same as the localised DD/MM/YYYY
format of the current date, display Today
: ((start(prop("Date")) < now() and end(prop("Date")) > now()) ? (format(dateBetween(end(prop("Date")), now(), "days")) + " days left")
Otherwise if the start date of
Date
is less than the current date and the end date of Date
is greater than the current date, display the number of days between the current date and the end date of Date
, then add days left
: ((end(prop("Date")) < now()) ? (format(abs(dateBetween(end(prop("Date")), now(), "days"))) + " days ago")
Otherwise if the end date of
Date
is less than the current date, display the number of days between the current date and the end date of Date
, then add days ago
: (format(ceil(dateBetween(prop("Date"), now(), "hours") / 24)) + " days away"))))
Otherwise display the rounded up number of days between the current date and the start date of
Date
, then add days away
Pluralised
empty(prop("Date")) ? "No Date" : ((formatDate(prop("Date"), "L") == formatDate(now(), "L")) ? "Today" : ((start(prop("Date")) < now() and end(prop("Date")) > now()) ? (format(ceil(dateBetween(end(prop("Date")), now(), "hours") / 24)) + " day" + ((dateBetween(end(prop("Date")), now(), "days") > 1) ? "s" : "") + " left") : ((end(prop("Date")) < now()) ? (format(abs(ceil(dateBetween(end(prop("Date")), now(), "hours") / 24))) + " day" + ((dateBetween(end(prop("Date")), now(), "days") < -1) ? "s" : "") + " ago") : (format(ceil(dateBetween(prop("Date"), now(), "hours") / 24)) + " day" + ((dateBetween(prop("Date"), now(), "days") > 1) ? "s" : "") + " away"))))
Commas
Regex with any
\
will fail upon subsequent saves as a second \
is added. In the formula below the two \d
in each pattern will become \\d
. Removing the second \
from each of the six \\d
will make the formula work again.This also seems to cause the numbers to disappear on Safari. Your mileage may vary.
empty(prop("Date")) ? "No Date" : ((formatDate(prop("Date"), "L") == formatDate(now(), "L")) ? "Today" : ((start(prop("Date")) < now() and end(prop("Date")) > now()) ? (format(replaceAll(ceil(dateBetween(end(prop("Date")), now(), "hours") / 24), "(?<=\d)(?=(\d{3})+$)", ",")) + " day" + ((dateBetween(end(prop("Date")), now(), "days") > 1) ? "s" : "") + " left") : ((end(prop("Date")) < now()) ? (format(replaceAll(abs(ceil(dateBetween(end(prop("Date")), now(), "hours") / 24)), "(?<=\d)(?=(\d{3})+$)", ",")) + " day" + ((dateBetween(end(prop("Date")), now(), "days") < -1) ? "s" : "") + " ago") : (format(replaceAll(ceil(dateBetween(prop("Date"), now(), "hours") / 24), "(?<=\d)(?=(\d{3})+$)", ",")) + " day" + ((dateBetween(prop("Date"), now(), "days") > 1) ? "s" : "") + " away"))))