<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> This formula determines the nth workday of the month. Holiday support is not currently included; the formula simply counts forward from the first workday of the month, skipping weekend days.
Created by Thomas Frank | Learn Notion Formulas | Notion Basics | Templates | Twitter
</aside>
lets(
/* Get the starting date and workday number */
startOfMonth, prop("Date").dateSubtract(prop("Date").date() - 1, "days"),
endOfMonth, prop("Date").dateAdd(1, "months").dateSubtract(prop("Date").date(), "days"),
workdayNum, prop("Workday Number"),
/* Determine the first workday */
firstWorkday, ifs(
startOfMonth.day() == 6, startOfMonth.dateAdd(2, "days"),
startOfMonth.day() == 7, startOfMonth.dateAdd(1, "days"),
startOfMonth
),
lastWorkday, ifs(
endOfMonth.day() == 6, endOfMonth.dateSubtract(1, "days"),
endOfMonth.day() == 7, endOfMonth.dateSubtract(2, "days"),
endOfMonth
),
daysBetween, dateBetween(lastWorkday, firstWorkday, "days"),
allDates, ","
.repeat(daysBetween)
.split(",")
.map(
firstWorkday.dateAdd(index, "days")
).filter(
current.day() < 6
),
finalWorkdayNum, min(workdayNum, allDates.length()) - 1,
selectedWorkday, allDates.at(finalWorkdayNum),
selectedWorkday
)