dateSubtract

Learn how to use the dateSubtract function in Notion formulas.

The dateSubtract() function accepts a date argument and subtracts from it, returning a new date.

dateSubtract(date, number, string [from unit list])

date.dateSubtract(number, string [from unit list])
Code language: JavaScript (javascript)

It requires three arguments in the following order:

  1. A date (must be an actual date data type)
  2. A number
  3. A unit

Accepted units include:

  • “years”
  • “quarters”
  • “months”
  • “weeks”
  • “days”
  • “hours”
  • “minutes”
  • “seconds”
  • “milliseconds”
/* Assume a property called "Date" with a current row value of June 1, 2022 */
dateSubtract(prop("Date"),3,"months") /* Output: March 1, 2022 */

prop("Date").dateSubtract(5, "days") /* Output: May 27, 2022 */
Code language: JavaScript (javascript)

You can nest multiple dateSubtract() functions to subtract multiple different types of units from a date:

/* Assume a property called "Date" with a current row value of June 1, 2022 */
prop("Date").dateSubtract(3, "months").dateSubtract(5, "days")
/* Output: February 24, 2022 */
Code language: JavaScript (javascript)

dateSubtract() accepts negative values:

/* Assume a property called "Date" with a current row value of June 1, 2022 */
dateSubtract(prop("Date"), -3, "months") /* Output: September 1, 2022 */
Code language: JavaScript (javascript)

This example database demonstrates how to output a date object set to January 1, 12:00 AM in the current year, in your current time zone.

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(
    dateSubtract(
        dateSubtract(
            dateSubtract(
                now(),
                minute(
                    now()
                ),
                "minutes"
            ),
            hour(
                now()
            ),
            "hours"
        ),
        date(
            now()
        ) - 1,
        "days"
    ),
    month(
        now()
    ),
    "months"
)
Code language: JavaScript (javascript)

This formula uses multiple instances of dateSubtract() to remove different units of time from the output of the now function in order to arrive at Jan 1, 12:00 AM.

The amount of time that is subtracted from now() is actually derived from now() itself. For example:

now().dateSubtract(
	now().minute()
	"minutes"
)
Code language: JavaScript (javascript)

Here, now().minute() gets the minute value from now().

So, if it’s currently 3:12 PM, this essentially says:

Subtract 12 minutes from 3:12 PM.

The resulting output would be 3:00 PM.

The formula then takes this output and does the same thing using hour, date, and month.

The only caveat is that 1 must be substracted from the output of date(), since there is no “January 0”.

Other formula components used in this example:

now – Thomas Frank
thomasjfrank.com
minute – Thomas Frank
thomasjfrank.com
hour – Thomas Frank
thomasjfrank.com
Create a Formula Property – Thomas Frank
thomasjfrank.com
month – 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