date

Learn how to use the date function in Notion formulas.

The date() function returns an integer (number) between 1 and 31 that corresponds to the day of the month of its date argument.

date(date)

date.date()
Code language: JavaScript (javascript)

date() (and its sibling functions minutehourdate, weekmonth, and year) is useful for manipulating dates within Notion formulas.

date(now()) /* Output: 24 (when now() = June 24, 2022) */

/* Assume a property called Date with a current date of June 1, 2022 11:29 AM */
prop("Date").date() /* Output: 1 */
Code language: JavaScript (javascript)

date() can be used with other functions such as dateSubtract to change the value of a date.

Here, it is used with dateSubtract and now to return a date at the start of the month.

/* Assume the value of now() is June 24, 2022 */
now().dateSubtract(now().date() - 1, "days")
/* Output: June 1, 2022 */
Code language: JavaScript (javascript)

Note that since the lowest integer value of date() is 1, I have to use now().date()-1 to get the first day of the month.

You can take this concept even further to “hard-code” any date into a Notion formula. See the section on Hard-Coding Dates into Formulas within the now article for more on how to do this.

This example database takes a date from the Date property and returns both the first and last day of the month that contains that date.

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
thomasfrank.notion.site
dateSubtract(
    prop("Date"),
    date(
        prop("Date")
    ) - 1,
    "days"
)
Code language: JavaScript (javascript)

To get the first day of the month, we simple subtract the date() integer (minus one) of the Date property from the Date property itself. We have to subtract one from the date() output in order to get to the 1st of the month – there’s no 0th day of the month!

dateSubtract(
    dateAdd(
        prop("Date"),
        1,
        "months"
    ),
    date(
        prop("Date")
    ),
    "days"
)
Code language: JavaScript (javascript)

The end of the month is a variable number. Some months have 31 days, some have 30, and one has 28… sometimes.

To solve for this, we first use dateAdd to add one month to Date property’s date. Then, we do the exact same date() subtraction operation described in the “First Day of the Month” section.

However, this time we don’t subtract one from date()‘s output, as we want to go one day further backwards from the 1st of the month.

Other formula components used in this example:

dateSubtract – Thomas Frank
thomasjfrank.com
dateAdd – Thomas Frank
thomasjfrank.com
subtract – Thomas Frank
thomasjfrank.com
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