The abs()
function calculates the absolute value of a number.
abs(number)
number.abs()
Code language: JavaScript (javascript)
A number’s absolute value is simply how far it is away from zero. Therefore, the absolute value of a negative number is equal to its positive equivalent – e.g. abs(-5) == 5.
In mathematical notation, absolute values are expressed by wrapping a number in || signs:
\(|-12\;| = 12\)Example Formulas
abs(-42) /* Output: 42 */
42.abs() /* Output: 42 */
Code language: JavaScript (javascript)
Example Database
Notion’s dateBetween function subtracts the second argument from the first, and returns a number depending on the specified unit of time (e.g. “hours” or “seconds”).
If the second argument is a later date than the first argument’s date, dateBetween()
will return a negative number. The formula in the table below uses the abs()
function to ensure that the output is always positive.
![](https://thomasjfrank.com/wp-content/uploads/2023/03/spaces_RJdJj77lj2q3xwMdOCbK_uploads_Qln49suI7DFMvmto7D5f_Absolute-Value-abs-Function-Notion-Formulas.webp)
View and Duplicate Database
![](https://www.notion.so/images/meta/default.png)
“Seconds Between” Property Formula
abs(dateBetween(prop("Date 1"), prop("Date 2"), "seconds"))
Code language: JavaScript (javascript)
Other formula components used in this example:
![](https://thomasjfrank.com/wp-content/uploads/2023/03/Notion-Formula-Reference-by-Thomas-Frank-thumbnail.jpg)