Skip to content

Instantly share code, notes, and snippets.

@thecist
Last active July 21, 2025 02:50
Show Gist options
  • Select an option

  • Save thecist/769699deae07a7baad6b9b8544d814e9 to your computer and use it in GitHub Desktop.

Select an option

Save thecist/769699deae07a7baad6b9b8544d814e9 to your computer and use it in GitHub Desktop.
Source code for due status in Notion Habits View Template by TheCist
lets(
first_day,
min(
if(contains(prop("Days"), "Sun"), 0, 7),
if(contains(prop("Days"), "Mon"), 1, 7),
if(contains(prop("Days"), "Tue"), 2, 7),
if(contains(prop("Days"), "Wed"), 3, 7),
if(contains(prop("Days"), "Thu"), 4, 7),
if(contains(prop("Days"), "Fri"), 5, 7),
if(contains(prop("Days"), "Sat"), 6, 7)
),
next_day,
min(
if(contains(prop("Days"), "Sun") && mod(day(now()), 7) <= 0, 0, 7),
if(contains(prop("Days"), "Mon") && mod(day(now()), 7) <= 1, 1, 7),
if(contains(prop("Days"), "Tue") && mod(day(now()), 7) <= 2, 2, 7),
if(contains(prop("Days"), "Wed") && mod(day(now()), 7) <= 3, 3, 7),
if(contains(prop("Days"), "Thu") && mod(day(now()), 7) <= 4, 4, 7),
if(contains(prop("Days"), "Fri") && mod(day(now()), 7) <= 5, 5, 7),
if(contains(prop("Days"), "Sat") && mod(day(now()), 7) <= 6, 6, 7)
),
week_duration,
ifs(
prop("Repeats Every (Weekly)").empty() || prop("Repeats Every (Weekly)")< 1,
1,
prop("Repeats Every (Weekly)")
),
weeks_ahead,
mod(
floor(
dateBetween(
dateSubtract(now(), mod(day(now()), 7), "days"),
dateSubtract(prop("Created time"), mod(day(prop("Created time")), 7), "days"),
"days"
) / 7
), week_duration
),
weeks_till_next,
if(
weeks_ahead == 0,
week_duration,
weeks_ahead
),
next_date,
ifs(
next_day != 7 && weeks_till_next == week_duration,
dateAdd(
now(),
next_day - mod(day(now()), 7),
"days"
),
dateAdd(
dateSubtract(
now(),
mod(day(now()), 7) - first_day,
"days"
),
weeks_till_next,
"weeks"
)
),
next_date,
dateAdd(
dateAdd(
next_date,
23 - hour(next_date),
"hours"
),
59 - minute(next_date),
"minute"
),
due_in,
dateBetween(next_date, now(), "days"),
ifs(
prop("Pause Habit")|| first_day == 7,
-1,
due_in
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment