The day()
function returns an integer (number) between 0
and 6
that corresponds to the day of the week of its date argument:

1
= Sunday 
2
= Monday 
3
= Tuesday  4 = Wednesday

5
= Thursday 
6
= Friday 
7
= Saturday
day(date) date.day()
day()
(and its sibling functions minute, hour, date, week, month, and year) is useful for manipulating dates within Notion formulas.
Example Formulas
day(now()) /* Output: 5 (when now() = June 24, 2022) */
/* Assume a property called Date with a current date of June 1, 2022 */
prop("Date").day() /* Output: 3 */
day()
can be used with other functions such as dateSubtract to change the value of a date.
/* Assume the value of now() is June 24, 2022 (Friday) */
dateSubtract(now(), day(now()), "days")
/* Output: June 19, 2022 (Sunday) */
You can take this concept even further to “hardcode” any date into a Notion formula. See the section on HardCoding Dates into Formulas within the now article for more on how to do this.
Additionally, day()
in particular is useful for determining weekdays and weekends:
/* Outputs, "It's the weekend!" if now()'s day is Saturday (6) or Sunday (7) */
now().day() == 6 or now().day() == 7 ? "It's the weekend!" : "It's a weekday."
/* This can also be accomplished like so: */
now().day().test("[67]") ? "It's the weekend!" : "It's a weekday."
Example Database
This example database finds the number of weekend days between two dates. If the starting and/or ending date is a weekend day, it is included in the count.
View and Duplicate Database
“Weekend Days” Property Formula
floor(
(
prop("Days Between") + day(
prop("Date 1")
)
) / 7
) * 2 + if(
day(
prop("Date 1")
) == 0,
1,
0
)  if(
day(
prop("Date 2")
) == 6,
1,
0
)
Let’s first cover the logic behind this formula:
First, we get the number of weekend days between our two dates, ignoring halfweekends. A halfweekend in the count occurs if:
 Date 1 (Start date) is Sunday
 Date 2 (End date) is Saturday
Then, to account for halfweekends, we run the following checks:
 If Date 1 is Sunday, we add 1.
 If Date 2 is Saturday, we subtract 1.
Now let’s talk about the formula.
To get the first count, which only counts full weekends, we find the number of days between Date 1 and Date 2 (stored in the Days Between property), and add to it the day()
integer returned from Date 1.
We divide that number by 7, then remove the trailing decimals by passing it through the floor function. We then multiply by 2, since there are two days per weekend:
floor(
(
prop("Days Between") + day(
prop("Date 1")
)
) / 7
) * 2
Note the use of parentheses here, which ensures the operations are carried out in the order we’ve specified above. To fully understand order of operations in Notion formulas, check out the operator precedence page.
Next, we check if Date 1 is Sunday, and if so, add 1:
if(day(prop("Date 1")) == 7, 1, 0)
Finally, we check if Date 1 is Saturday, and if so, subtract 1:
if(day(prop("Date 2")) == 6, 1, 0)
Credit is due to IBM; I found the solution to this problem in their documentation for their Cognos Business Intelligence Platform: