and

Learn how to use the Boolean "and" operator in Notion formulas.

The and operator returns true if and only if both of its operands have a `true` Boolean value. Otherwise, it will return false. It accepts Boolean operands.

``````Boolean and Boolean
and(Boolean, Boolean)
Boolean && Boolean
```Code language: JavaScript (javascript)```

And is useful for testing that two or more things are true.

Good to know: Notion is no longer picky, so `&&``AND`, and `And` now also work.

You can also use the function version, `and()`.

``````true and true /* Output: true */

true && false /* Output: false */

and(1 > 0, 0 < 4) /* Output: true */

if(true and true, "Happy", "Sad") /* Output: "Happy" */

if(5 > 4 and 1 < 3, true, false) /* Output: true */

if(length("Monkey D. Luffy") > 5 and length("Monkey D. Luffy") < 100, true, false) /* Output: true */
```Code language: JavaScript (javascript)```

The `and` operator can also be chained together multiple times:

``````4 > 2 and 3 < 4 and 5 > 2 and 7 == 7 ? true : false /* Output: true */
```Code language: JavaScript (javascript)```

The example database below shows a list of shore leave requests from a pirate crew. The captain will only approve a request if both are true:

• The request doesn’t fall on one of that crew member’s watch duty days
• The crew member has less than \$10,000 in gambling debt

The Approved? formula uses the and operator to ensure that both of these conditions are true. If so, it’ll output `true` and the request will be approved. If not, it’ll output `false` and the request will be denied.

``````// Compressed
if(prop("Gambling Debt") < 10000 and not contains(prop("Watch Duty Days"), formatDate(prop("Request Date"), "dddd")), true, false)

// Expanded
if(
prop("Gambling Debt") < 10000
and
not contains(
prop("Watch Duty Days"),
formatDate(
prop("Request Date"),
"dddd"
)
),
true,
false
)
```Code language: JavaScript (javascript)```

This formula uses an if statement to check that both of the captain’s conditions are true:

• The first operand checks that the crew member’s gambling debt is `< 10000`
• The second operand checks the request date against the crew member’s assigned watch days:
• The contains function checks to see if the Request Date’s day of the week is contained in the Watch Duty Days list for each row.
• The formatDate function uses the Moment.js string `dddd` to convert the Request Date into a named day of the week (i.e. “Wednesday”) so it can be compared against the tags in the Watch Duty Days property.
• Finally, the not operator negates the boolean output of the `contain()` function, ensuring the `and` operator only returns `true` if the Request Date DOESN’T match an assigned Watch Duty Day.