The dateAdd()
function accepts a date argument and adds to it, returning a new date.
dateAdd(date, number, string [from unit list])
date.dateAdd(number, string [from unit list])
Code language: JavaScript (javascript)
It requires three arguments in the following order:
Accepted units include:
- “years”
- “quarters”
- “months”
- “weeks”
- “days”
- “hours”
- “minutes”
- “seconds”
- “milliseconds”
Example Formulas
/* Assume a property called "Date" with a current row value of June 1, 2022 */
dateAdd(prop("Date"),3,"months") /* Output: September 1, 2022 */
dateAdd(prop("Date"),5,"days") /* Output: June 6, 2022 */
Code language: JavaScript (javascript)
You can nest multiple dateAdd()
functions to add multiple different types of units to a date:
/* Assume a property called "Date" with a current row value of June 1, 2022 */
dateAdd(dateAdd(prop("Date"),3,"months"),5,"days")
/* Output: September 6, 2022 */
Code language: JavaScript (javascript)
dateAdd()
accepts negative values:
/* Assume a property called "Date" with a current row value of June 1, 2022 */
dateAdd(prop("Date"), -3, "months") /* Output: March 1, 2022 */
Code language: JavaScript (javascript)
Example Database
This example database demonstrates a very simple way to track recurring tasks in Notion. The Next Due formula returns the next due date for the task, based on the current Due date and the number of days specified in the Interval (Days) property.
View and Duplicate Database
“Next Due” Property Formula
// Compressed
dateAdd(prop("Due"),prop("Interval"),prop("Unit") + "s")
// Expanded
dateAdd(
prop("Due"),
prop("Interval"),
prop("Unit") + "s"
)
Code language: JavaScript (javascript)
As you can see, this formula is quite simple. If you’re not worried about accounting for overdue tasks, returning the “next due” date for a recurring task is quite easy.
Using dateAdd()
, all we are three pieces of information:
- The original due date
- The interval (a number)
- The unit (e.g. days, weeks, months, years)
The value from the Unit property is concatenated with “s” in order to make it conform to dateAdd()
‘s accepted values.
Of course, handling recurring tasks can get much more complicated if you do want to handle overdue tasks. If you want to see just how big a Notion formula can get, check out the recurring tasks formula we developed for my Ultimate Tasks and Ultimate Brain templates: