toNumber
Learn how to use the toNumber function in Notion formulas.
The toNumber() function converts its argument to a number if it can do so. It is useful for converting strings, Booleans, and dates to numbers.
1
toNumber(string)
2
toNumber(Boolean)
3
toNumber(date)
Unlike unaryPlus, toNumber() can convert dates to numbers. When used to convert a date, toNumber will convert it to its corresponding Unix timestamp; this behavior matches that of the timestamp function.
Good to know: If a string starts with a number and contains letter chracters as well,toNumber() will return just that starting number. However, if the string does not start with a number, toNumber() will output nothing – even if the string contains a number elsewhere.

1
toNumber("42") // Output: 42 (number)
2
​
3
toNumber("42 rabbits jump 100 times") // Output: 42
4
​
5
toNumber("I have 42 rabbits.") // Output: blank
6
​
7
toNumber(true) // Output: 1
8
​
9
toNumber(false) // Output: 0
10
​
11
toNumber(5>3) // Output: 1
12
​
13
toNumber(now()) // Output: 1655757000000 (changes with now()'s value)

This example database is a simple habit tracker. Each property represents a different habit, and the Habits formula property adds them up and outputs a string reporting the number of habits completed on that day.

toNumber
College Info Geek on Notion

1
// Compressed
2
format(toNumber(prop("πŸ’§")) + toNumber(prop("πŸƒβ€β™‚οΈ")) + toNumber(prop("πŸ‹οΈβ€β™€οΈ")) + toNumber(prop("πŸ₯¦"))) + "/4" + if((toNumber(prop("πŸ’§")) + toNumber(prop("πŸƒβ€β™‚οΈ")) + toNumber(prop("πŸ‹οΈβ€β™€οΈ")) + toNumber(prop("πŸ₯¦"))) == 1," Habit"," Habits")
3
​
4
// Expanded
5
format(
6
toNumber(
7
prop("πŸ’§")
8
) +
9
toNumber(
10
prop("πŸƒβ€β™‚οΈ")
11
) +
12
toNumber(
13
prop("πŸ‹οΈβ€β™€οΈ")
14
) +
15
toNumber(
16
prop("πŸ₯¦")
17
)
18
) +
19
"/4" +
20
if(
21
(
22
toNumber(
23
prop("πŸ’§")
24
) +
25
toNumber(
26
prop("πŸƒβ€β™‚οΈ")
27
) +
28
toNumber(
29
prop("πŸ‹οΈβ€β™€οΈ")
30
) +
31
toNumber(
32
prop("πŸ₯¦")
33
)
34
) == 1,
35
" Habit",
36
" Habits"
37
)
This formula uses toNumber() to convert the Boolean output of each habit’s checkbox value into a number - either 1 or 0. It then adds up all the numbers to get a total number of habits completed for the day.
The format function is then used to convert this number into a string so that it can be combined with the other string elements in the formula.
Finally, an if statement uses the same process to determine if the total number of habits completed is equal to 1. If so, it outputs β€œHabit”; if not, it outputs the plural β€œHabits”.

​
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 7d ago
Copy link
On this page
Example Formulas
Example Database
View and Duplicate Database
β€œHabits” Property Formula