Red Gregory

View Original

Notion Formula: Remaining Days, Hours, MInutes (via Dates With Time Values)

Full Formula

if(contains(formatDate(prop("Deadline"), "MMM DD, YYYY"), formatDate(now(), "MMM DD, YYYY")) and hour(prop("Deadline")) == 0, "🔔Today", if(contains(formatDate(prop("Deadline"), "MMM DD, YYYY"), formatDate(now(), "MMM DD, YYYY")) and hour(prop("Deadline")) > hour(now()), "🔔" + format(ceil(dateBetween(prop("Deadline"), now(), "hours"))) + "H : " + format(dateBetween(prop("Deadline"), now(), "minutes") % 60) + "M", if(prop("Deadline") > now() and hour(prop("Deadline")) == 0, format(ceil(dateBetween(prop("Deadline"), now(), "hours") / 24)) + "D ▶︎", if(prop("Deadline") > now(), concat(format(floor(dateBetween(prop("Deadline"), now(), "hours") / 24)), "D : ", format(ceil(dateBetween(prop("Deadline"), now(), "hours") % 24)), "H ▶︎"), if(formatDate(prop("Deadline"), "MMM DD, YYYY") < formatDate(now(), "MMM DD, YYYY"), "◀︎ " + format(abs(floor(dateBetween(prop("Deadline"), now(), "hours") / 24))) + "D", "🔔Earlier")))))

5 Conditions (Breakdown)

*These conditions are formatted to work alone if you want to grab them individually

If today without time, return today

if(contains(formatDate(prop("Deadline"), "MMM DD, YYYY"), formatDate(now(), "MMM DD, YYYY")) and hour(prop("Deadline")) == 0, "🔔Today", "")

If within today and in the future, return hours + minutes remaining

if(contains(formatDate(prop("Deadline"), "MMM DD, YYYY"), formatDate(now(), "MMM DD, YYYY")) and hour(prop("Deadline")) > hour(now()), "🔔" + format(ceil(dateBetween(prop("Deadline"), now(), "hours"))) + "H : " + format(dateBetween(prop("Deadline"), now(), "minutes") % 60) + "M", "")

If future without time, return days remaining

if(prop("Deadline") > now() and hour(prop("Deadline")) == 0, format(ceil(dateBetween(prop("Deadline"), now(), "hours") / 24)) + "D ▶︎", "")

If future with time, return days + hours remaining

if(prop("Deadline") > now(), concat(format(floor(dateBetween(prop("Deadline"), now(), "hours") / 24)), "D : ", format(ceil(dateBetween(prop("Deadline"), now(), "hours") % 24)), "H ▶︎"), "")

If past ≤ -1 day, return days past

if(formatDate(prop("Deadline"), "MMM DD, YYYY") < formatDate(now(), "MMM DD, YYYY"), "◀︎ " + format(abs(floor(dateBetween(prop("Deadline"), now(), "hours") / 24))) + "D", "")

False Condition

"🔔Earlier"

See this content in the original post

View Example In Notion


See this gallery in the original post