<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a5a1e3ce-00fa-46e4-9a75-58c2aed9e8ce/Notion_Fundamentals_with_Thomas_Frank_-_Avatar_2021.png" width="40px" /> This example database uses the Birth Date property to determine the age of each person. Additional logic is included to deal with plurality (”year” vs “years”), and to express infant age in months.

Created by Thomas Frank | Learn Notion Formulas | Notion Basics | Templates | Twitter

</aside>

Ages of People

“Age” Property

dateBetween(now(), prop("Birth Date"), "years")

“Age (Pretty)” Property

// Compressed
prop("Name") + " is " + if(dateBetween(now(), prop("Birth Date"), "years") < 1, format(dateBetween(now(), prop("Birth Date"), "months")) + if(dateBetween(now(), prop("Birth Date"), "months") == 1, " month old.", " months old."), format(dateBetween(now(), prop("Birth Date"), "years")) + if(dateBetween(now(), prop("Birth Date"), "years") == 1, " year old.", " years old."))

// Expanded
prop("Name") + " is " + 
if(
    dateBetween(
        now(),
        prop("Birth Date"),
        "years"
    ) < 1,
    format(
        dateBetween(
            now(),
            prop("Birth Date"),
            "months"
        )
    ) + if(
        dateBetween(
            now(),
            prop("Birth Date"),
            "months"
        ) == 1,
        " month old.",
        " months old."
    ),
    format(
        dateBetween(
            now(),
            prop("Birth Date"),
            "years"
        )
    ) + if(
        dateBetween(
            now(),
            prop("Birth Date"),
            "years"
        ) == 1,
        " year old.",
        " years old."
    )
)

© Thomas Frank