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.

toNumber(string) toNumber(Boolean) 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.

toNumber("42") // Output: 42 (number) toNumber("42 rabbits jump 100 times") // Output: 42 toNumber("I have 42 rabbits.") // Output: blank toNumber(true) // Output: 1 toNumber(false) // Output: 0 toNumber(5>3) // Output: 1 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.

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
// Compressed format(toNumber(prop("💧")) + toNumber(prop("🏃‍♂️")) + toNumber(prop("🏋️‍♀️")) + toNumber(prop("🥦"))) + "/4" + if((toNumber(prop("💧")) + toNumber(prop("🏃‍♂️")) + toNumber(prop("🏋️‍♀️")) + toNumber(prop("🥦"))) == 1," Habit"," Habits") // Expanded format( toNumber( prop("💧") ) + toNumber( prop("🏃‍♂️") ) + toNumber( prop("🏋️‍♀️") ) + toNumber( prop("🥦") ) ) + "/4" + if( ( toNumber( prop("💧") ) + toNumber( prop("🏃‍♂️") ) + toNumber( prop("🏋️‍♀️") ) + toNumber( prop("🥦") ) ) == 1, " Habit", " Habits" )

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”.

Other formula components used in this example:

format – Thomas Frank
if – Thomas Frank
add – Thomas Frank
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