Formula Components

Formulas and Databases

Reference

Formula Examples

day

Learn how to use the day function in Notion formulas.

`0`

= Sunday`1`

= Monday`2`

= Tuesday`3`

= Wednesdy`4`

= Thursday`5`

= Friday`6`

= Saturday

1

day(date)

1

day(now()) // Output: 5 (when now() = June 24, 2022)

2

โ

3

// Assume a propety called Date with a current date of June 1, 2022

4

day(prop("Date")) // Output: 3

1

// Assume the value of now() is June 24, 2022 (Friday)

2

dateSubtract(now(), day(now()), "days")

3

// Output: June 19, 2022 (Sunday)

You can take this concept even further to โhard-codeโ any date into a Notion formula. See the section on Hard-Coding 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:1

// Outputs, "It's the weekend!" if now()'s day is Saturday (6) or Sunday (0)

2

day(now()) == 0 or day(now()) == 6 ? "It's the weekend!" : "It's a weekday."

3

โ

4

// This can also be accomplished like so:

5

test(format(day(now())),"[06]") ? "It's the weekend!" : "It's a weekday."

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.

day

College Info Geek on Notion

1

// Compressed

2

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)

3

โ

4

// Expanded

5

floor(

6

(

7

prop("Days Between") + day(

8

prop("Date 1")

9

)

10

) / 7

11

) * 2 + if(

12

day(

13

prop("Date 1")

14

) == 0,

15

1,

16

0

17

) - if(

18

day(

19

prop("Date 2")

20

) == 6,

21

1,

22

0

23

)

Let's first cover the **logic** behind this formula:

First, we get the number of weekend days between our two dates, ignoring half-weekends. A half-weekend in the count occurs if:

- Date 1 (Start date) is Sunday
- Date 2 (End date) is Saturday

Then, to account for half-weekends, 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:

1

floor(

2

(

3

prop("Days Between") + day(

4

prop("Date 1")

5

)

6

) / 7

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:

1

if(day(prop("Date 1")) == 0, 1, 0)

Finally, we check if Date 1 is Saturday, and if so, subtract 1:

1

if(day(prop("Date 2")) == 6, 1, 0)

Calculate the number of Weekdays between two dates

โ My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

Last modified 21d ago

Copy link

On this page

Example Formulas

Example Database

View and Duplicate Database

"Weekend Days" Property Formula