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

Screen Shot 2020-09-07 at 3.17.48 PM.png

🔔 Day & Time Remaining

As an extension of this blog post, I want to show you how a user can return a similar formula upon the addition of time values. There are 5 conditions in this formula which include future, present, and past deadlines that are sensitive to dates with and without 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"