# Functions

Learn how to use the built-in functions within Notion formulas.
In programming, a function is a reusable bundle or "chunk" of code. Functions have names which, when called elsewhere in the program, execute the function's code.
Functions can also take in outside data (these are called arguments), and return new data.
In Notion formulas, you cannot define your own functions. However, Notion has provided many built-in functions you can use.
For example, the length function takes in a string argument and outputs a number equal the number of characters in that string.
1
length("Monkey D. Luffy") // Output: 15
Here's a list of every function available for use in a Notion formula. Click a function to learn more about how it works and see more examples.
Function
Data Output Type
Example
Output
concat
String
`concat("Roronoa "," Zoro")`
Roronoa Zoro
join
String
`join(", ","Luffy ","Zoro","Nami","Chopper")`
Luffy, Zoro, Chopper
slice
String
`slice("Dangerfield",0,6)`
Danger
length
Number
`length("Monkey D. Luffy")`
15
format
String
`format(4)`
4 (as a string)
toNumber
Number
`toNumber("42")`
42 (as a number)
contains
Boolean
`contains("Monkey D. Luffy", "Luffy")`
True
replace
String
`replace("Pogo","Po","Dog")`
Doggo
String
`replaceAll("Dogs Dogs Dogs","Dogs","Cats")`
Cats Cats Cats
test
Boolean
`test("Monkey D. Luffy", "Luffy")`
True
empty
Boolean
`empty("")`
True
abs
Number
`abs(-42)`
42
cbrt
Number
`cbrt(64)`
4
ceil
Number
`ceil(4.2)`
5
exp
Number
`exp(2)`
7.389056098931
floor
Number
`floor(4.2)`
4
ln
Number
`ln(20)`
2.995732273554
log10
Number
`log10(1000)`
3
log2
Number
`log2(64)`
6
max
Number
`max(3,5,4)`
5
min
Number
`min(4,1,9,-3)`
-3
round
Number
`round(4.5)`
5
sign
Number
`sign(-5)`
-1
sqrt
Number
`sqrt(16)`
4
start
Date
`start(prop("Date"))`
August 18, 2022
end
Date
`end(prop("Date"))`
August 25, 2022
now
Date
`now()`
August 18, 2022 2:10 PM
timestamp
Number
`timestamp(now())`
1660853460000
Date
`fromTimestamp(1656012840000)`
June 23, 2022 1:34 PM
Date
`dateAdd(now(),3,"months")`
November 18, 2022 2:11 PM
Date
`dateSubtract(now(),3,"months")`
May 18, 2022 2:11 PM
Number
`dateBetween(now(),prop("Date"),"days")`
9
String
`formatDate(now(), "MMMM DD YYYY")`
August 18 2022
minute
Number
`minute(now())`
9
hour
Number
`hour(now())`
14
day
Number
`day(now())`
4
date
Number
`date(now())`
18
month
Number
`month(now())`
7
year
Number
`year(now())`
2022
id
String
`id()`
c5d67d15854744869cc4a062fb7b1377

## Functions as Arguments

Functions can accept other functions as arguments, so long as the inner function outputs the data type that the outer function requires.
Here are a couple examples:
1
slice(format(1932),0,2)
2
// Output: 19
3
4
// Expanded form
5
slice(
6
format(1932),
7
0,
8
2
9
)
10
11
---
12
13
// Get the century name (e.g. "20th") from a year (expressed as a number)
14
15
// Output: 20th
16
17
// Expanded form
18
concat(
19
format(
20
21
toNumber(
22
slice(
23
format(1932),
24
0,
25
2
26
)
27
),
28
1
29
)
30
),
31
"th"
32
)
For more examples, see the example databases for most of the functions. The majority in this reference use other functions as arguments in order to do useful things. To start, I'll recommend checking out the format function's example database. 