9 Useful Date And Time Notion Formulas
How To Use The Formulas
Replace prop(“Date w/ Time”) with name of date property with time included.
Replace prop(“Date Range”) with name of date property as date range with time included.
1. Find Today From Date With Time
formatDate(prop("Date w/ Time"), "L") == formatDate(now(), "L")
2. Find Tomorrow From Date With Time
formatDate(dateAdd(now(), 1, "days"), "L") == formatDate(prop("Date w/ Time"), "L")
3. Find Hours Between Date Range
floor(100 * dateBetween(end(prop("Date Range")), start(prop("Date Range")), "minutes") / 60) / 100
4. Find Days Left To Date With Time
if(formatDate(dateAdd(now(), 1, "days"), "L") == formatDate(prop("Date w/ Time"), "L"), 1, if(dateSubtract(prop("Date w/ Time"), hour(prop("Date w/ Time")), "hours") < now(), dateBetween(dateSubtract(prop("Date w/ Time"), hour(prop("Date w/ Time")), "hours"), now(), "days"), dateBetween(dateSubtract(prop("Date w/ Time"), hour(prop("Date w/ Time")), "hours"), now(), "days") + 1))
5. Find Days And Hours Left To Date
if(dateBetween(dateSubtract(prop("Date w/ Time"), hour(prop("Date w/ Time")), "hours"), dateSubtract(now(), hour(now()), "hours"), "days") < 0, "Past Date", if(formatDate(prop("Date w/ Time"), "L") == formatDate(now(), "L"), format(dateBetween(prop("Date w/ Time"), now(), "hours")) + " hr(s)", if(prop("Date w/ Time") > now(), format(dateBetween(dateSubtract(prop("Date w/ Time"), hour(prop("Date w/ Time")), "hours"), now(), "days") + 1) + " dy(s) " + format(hour(prop("Date w/ Time"))) + " hr(s)", "")))
6. Find Time Of Day From Date
if(hour(prop("Date w/ Time")) < 12, "Morning", if(hour(prop("Date w/ Time")) < 17, "Afternoon", if(hour(prop("Date w/ Time")) < 24, "Evening", "")))
7. Find Hours And Minutes Between Date Range
if(not empty(prop("Date Range")), format(dateBetween(end(prop("Date Range")), start(prop("Date Range")), "hours")) + " hr(s) " + format(dateBetween(end(prop("Date Range")), start(prop("Date Range")), "minutes") % 60) + " min(s)", "")
8. Find Percentage Of Day Complete
No other property outside the formula is needed.
slice("▒▒▒▒▒▒▒▒▒▒", 0, floor(10 * hour(now()) / 24)) + "|" + slice("░░░░░░░░░░", 0, 10 - floor(10 * hour(now()) / 24)) + " " + format(floor(100 * hour(now()) / 24)) + "%”
9. Format A Unique Timestamp
The Created property is a Created time property and is required for this formula.
formatDate(prop("Created"), "YYYYMMDDhhmm")