Formula Components

Formulas and Databases

Reference

Formula Examples

equal

Learn how to use the Boolean "equal" (==) operator in Notion formulas.

1

string == string

2

number == number

3

Boolean == Boolean

4

date == date

5

β

6

equal(string, string)

7

equal(number, number)

8

equal(Boolean, Boolean)

9

equal(date, date)

`===`

is not supported (You can also use the function version,

`equal()`

.1

1 == 1 // Output: True

2

β

3

equal(1,1) // Output: True

4

β

5

1 == 2 // Output: False

6

β

7

"1" == 1 // Type mismatch error

8

β

9

+"1" == 1 // Output: True (uses the unaryPlus operator to convert "1" to a number

10

β

11

2^2 == 4 // Output: True

12

β

13

length("Monkey D. Luffy") == 15 // Output: True

`==`

) operator `1 == 1 ==1`

won't work. Use the and operator to get around this - e.g. `1 == 1 and 1 == 1`

.The example database below shows several rows with random dates. The **Last Weekday** property displays the last weekday in that dateβs month, and then the **Day Name** property shows which day of the week it is.

equal

College Info Geek on Notion

`!=`

) operator's page. These operators are opposites, but their usage (and operator precedence) is the same.To get the last weekday of the month in a Notion formula, we follow this process:

- 1.First, obtain the last day of the month:
- 1.
- 2.Subtract
`x`

days from the resulting date using dateSubtract(), where`x`

is that date's date index (E.g.`June 11`

would have a date index of`11`

) - 3.Since all months start on the 1st, this will always get you to the last day of the preceding month. (e.g.
`June 11 - 11 == May 31`

).

- 2.Next, check if the last day of the month is a Sunday using date(). If so, subtract 2 days from it and output the resulting date, which will be a Friday.
- 3.If the last day of the month isn't a Sunday, check if it's a Saturday. If so, subtract 1 day from it and output the resulting date, which will be a Friday.
- 4.If the last day of the month isn't a Sunday or Saturday, simply output it.

To keep this example simple and easy to follow, I've created the **Last Day **property to act as a variable that we can call from the **Last Weekday **formula.

Finally, the **Day Name **property uses the formatDate() function to display the actual day of the week that corresponds to **Last Weekday's **date.

1

// Compressed

2

if(day(prop("Last Day")) == 0, dateSubtract(prop("Last Day"),2,"days"), if(day(prop("Last Day")) == 6, dateSubtract(prop("Last Day"),1,"days"),prop("Last Day")))

3

β

4

// Expanded and Commented

5

if(

6

β

7

// Check if the day of the week index for Last Day

8

// is 0 (Sunday).

9

day(

10

prop("Last Day")

11

) == 0,

12

13

// If it is 0, subtract 2 days from Last Day to arrive at the

14

// nearest weekday (Friday).

15

dateSubtract(

16

prop("Last Day"), 2, "days"

17

),

18

19

// If it isn't 0, next check if the day of the week index

20

// for Last Day is 6 (Saturday).

21

if(

22

day(

23

prop("Last Day")

24

) == 6,

25

26

// If it is 6, subtract 1 day from Last Day to arrive at

27

// the nearest weekday (Friday).

28

dateSubtract(

29

prop("Last Day"), 1, "days"

30

),

31

32

// If the day of the week index isn't 0 or 6, output the

33

// Last Day property as-is.

34

prop("Last Day")

35

)

36

)

1

// Compressed

2

dateSubtract(dateAdd(prop("Date"), 1, "months"), date(dateAdd(prop("Date"), 1, "months")), "days")

3

β

4

// Expanded and Commented

5

β

6

// Get the last day of the current month by adding 1 month to the current Date,

7

// then subtracting the number of days in that date's date() index.

8

dateSubtract(

9

β

10

// Add 1 month to the current date.

11

// E.g. - May 11 + 1 month == June 11

12

dateAdd(

13

prop("Date"), 1, "months"

14

),

15

β

16

// Get the number of days to be subtracted using the date()

17

// function. E.g. - June 11 == 11

18

date(

19

dateAdd(

20

prop("Date"), 1, "months"

21

)

22

),

23

β

24

// Specify the date unit to be subtracted; in this case, "days"

25

"days"

26

)

Combined Formula without Using "Last Day" Property

β 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

Last Weekday Explanation

"Last Weekday" Property Formula

"Last Day" Property Formula