# Converting Data Types

Learn how to convert data to another type in a Notion formula.
Notion formulas can only return data of a single type. For reference, Notion formulas work with four distinct data types:
Additionally, you can only compare data that share the same type when you use comparison operators such as equal, and, or larger (and some require a specific data type).
Therefore, you'll often need to convert data from one type to another in order to get your formula to work.
Here are all the methods you can use to convert data to another type.

## Converting Strings

To numbers:
Function/Method
Example
toNumber
`toNumber("42")`
unaryPlus (`+`)
`+"42"`
To Booleans:
Function/Method
Example
if
`if(prop("Text") == "true", true, false)`
Good to know: You can't truly convert strings, numbers, or dates to Boolean values. What you can do is write a simple statement that outputs a Boolean true/false value using your starting piece of data as criteria.

## Converting Numbers

To strings:
Function/Method
Example
format
`format(42)`
To Booleans:
Function/Method
Example
if
`if(prop("Num") == 42, true, false)`
To dates:
Function/Method
Example
`fromTimestamp(prop("Num"))`
Note: fromTimestamp only works if its argument is a valid Unix timestamp.
Good to know: replace, replaceAll, and test are able to automatically convert numbers and Booleans (but not dates) to strings. Manual type conversion is not needed.

## Converting Booleans

To strings:
Function/Method
Example
format
`format(true)`
To numbers:
Function/Method
Example
toNumber
`toNumber(true)`
unaryPlus (`+`)
`+true`

## Converting Dates

To strings:
Function/Method
Example
format
`format(now())`
`formatDate(now(), "MMM DD YYYY")`
To numbers:
Function/Method
Example
timestamp
`timestamp(now())`
toNumber
`toNumber(now())`
minute
`minute(now())`
hour
`hour(now())`
day
`day(now())`
date
`date(now())`
month
`month(now())`
year
`year(now())`
Good to know: The toNumber function converts dates to their Unix timestamp, just like the timestamp function.
To Booleans:
Function/Method
Example
if
`if(prop("Date") == now(), true, false)`