Skip to content

Instantly share code, notes, and snippets.

@typeoneerror
Last active September 16, 2023 15:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save typeoneerror/35cb4201d982794d56e2c5945e4213a3 to your computer and use it in GitHub Desktop.
Save typeoneerror/35cb4201d982794d56e2c5945e4213a3 to your computer and use it in GitHub Desktop.
Days left in Notion
lets(
nowVal, now(),
/* We need now as just a date with no time */
nowDate, nowVal.formatDate("YYYY-MM-DD").parseDate(),
dueDate, prop("Due Date").formatDate("YYYY-MM-DD").parseDate(),
/* Days between now and the due date */
days, dateBetween(dueDate, nowDate, "days"),
/* Now we switch on the conditions */
ifs(
/* Date is unset */
empty(prop("Due Date")), "No date".style("grey", "i"),
/* No diff is today */
days == 0, "Today".style("red"),
/* +1 is tomorrow */
days == 1, "Tomorrow".style("orange"),
/* -1 is yesterday */
days == -1, "❗️ Yesterday".style("red", "b"),
/* well overdue! */
days < -1, ("‼️ " + abs(days) + " days ago").style("red", "b"),
/* positive days remain */
days + " days left"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment