equal

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

The equality (==) operator returns true if its operands are equal. It accepts operands of all data typesstrings, numbers, Booleans, and dates.

string == string
number == number
boolean == boolean
date == date
list == list

equal(string, string)
equal(number, number)
equal(boolean, boolean)
equal(date, date)
equal(list, list)

string.equal(string)
number.equal(number)
boolean.equal(boolean)
date.equal(date)
list.equal(list)
Code language: JavaScript (javascript)

Good to know: Notion now allows for comparisons between different data types, and the equality operator (==) will act as a strict equality operator. For example, "1" == 1 will return false

You can also use the function version, equal().

1 == 1 /* Output: true */

equal(1, 1) /* Output: true */

1.equal(1) /* Output: true */

1 == 2 /* Output: false */

"1" == 1 /* Output: false */

toNumber("1") == 1 /* Output: true */

2^2 == 4 /* Output: true */

length("Monkey D. Luffy") == 15 /* Output: true */
Code language: JavaScript (javascript)

Good to know: The equality (==) operator cannot be chained in a Notion formula. A formula like 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.

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team
thomasfrank.notion.site

Want a simpler example? Check out the one on the inequality (!=) 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.
    • Start with a lets function to allow for multiple variables to be set.
    • Create a date variable and assign it the following: Add 1 month to the current date in the Date property, using dateAdd().
    • Create a lastDay variable and assign it the following: 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)
    • 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 Saturday (6) or a Sunday (7) using day(). If so, add the corresponding day number to -5, and then subtract that number of days from lastDay, which will give you Friday.
  3. If the last day of the month isn’t a Sunday or Saturday, simply output lastDay.

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

let(
	lastDay, parseDate("2023-08-31"),
	lastDay.day() == 6 or lastDay.day() == 7
		? lastDay.dateSubtract(-5 + lastDay.day(), "days")
		: lastDay
)

/* Explained */
let(
	/* Create a lastDay variable of August 31, 2023 */
	lastDay, parseDate("20230831"),

	/* Check if the day number of lastDay is 6 (Saturday) or 7 (Sunday) */
	lastDay.day() == 6 or lastDay.day() == 7, 
	
		/* If it is, add that day number to -5 to get 1 or 2, 
			 then subtract that number of days from lastDay */
		lastDay.dateSubtract(-5 + lastDay.day(), "days"),

		/* Otherwise display lastDay as is */
		lastDay
)
Code language: JavaScript (javascript)
lets(
	nowDate, now().formatDate("YYYYMMDD").parseDate(),
	newDate, nowDate.dateAdd(1, "months"),
	newDate.dateSubtract(newDate.date(), "days")
)

/* Explained */
lets(

	/* Create a nowDate variable with the current date */
	nowDate, 
	now().formatDate("YYYYMMDD").parseDate(),

	/* Create a newDate variable that adds 1 month to nowDate */
	newDate, 
	nowDate.dateAdd(1, "months"),

	/* Get the day of the month number of newDate, 
	   then subtract that number of days from newDate */
	newDate.dateSubtract(
		newDate.date(), 
		"days"
	)

)
Code language: JavaScript (javascript)

If you’re curious, here’s how you could create a single mega-formula that can find the last weekday of the month without the need for a Last Day variable property:

lets(
	date, prop("Date").dateAdd(1, "months"),
	lastDay, date.dateSubtract(date.date(), "days"),
	lastDay.day() == 6 or lastDay.day() == 7
		? lastDay.dateSubtract(-5 + lastDay.day(), "days") 
		: lastDay 
)

/* Explained */
lets(

	/* Add 1 month to Date and create a date variable from the result */
	date, prop("Date").dateAdd(1, "months"),

	/* Get the day of the month number of date, 
	   subtract that number of days from date,
		 then create a lastDay variable from the result */
	lastDay, date.dateSubtract(date.date(), "days"),
	
	/* Check if the day number of lastDay is 6 (Saturday) or 7 (Sunday) */
	lastDay.day().test("6|7"),

		/* If it is, add the day number to -5 to get 1 or 2, 
			 then subtract that number of days from lastDay */
		? lastDay.dateSubtract(-5 + lastDay.day(), "days"),

		/* Otherwise, display lastDay as is */
		: lastDay

)
Code language: JavaScript (javascript)

Other formula components used in this example:

if – Thomas Frank
thomasjfrank.com
dateAdd – Thomas Frank
thomasjfrank.com
dateSubtract – Thomas Frank
thomasjfrank.com
date – Thomas Frank
thomasjfrank.com
day – Thomas Frank
thomasjfrank.com
formatDate – Thomas Frank
thomasjfrank.com
About the Author

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.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas