The minute()
function returns an integer (number) between 0
and 59
that corresponds to the minute of its date argument.
minute(date)
date.minute()
Code language: JavaScript (javascript)
minute()
(and its sibling functions hour, day, date, month, week, and year) is useful for manipulating dates within Notion formulas.
Example Formulas
minute(now()) /* Output: 25 (When current time was 11:25 AM) */
/* Assume a property called Date with a current date of June 24, 2022 11:29 AM */
prop("Date").minute() /* Output: 29 */
Code language: JavaScript (javascript)
minute()
can be used with other functions such as dateSubtract to change the value of a date, like so:
/* Assume the value of now() is June 24, 2022 11:34 AM */
now().dateSubtract(now().minute(), "minutes")
/* Output: June 24, 2022 11:00 AM */
Code language: JavaScript (javascript)
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.
Example Database
This example database shows both the current time (using the now function), as well as the current time rounded to the nearest hour.
View and Duplicate Database
“Nearest Hour” Property Formula
let(
minute, now().minute(),
if(
minute < 30,
dateSubtract(
now(),
minute,
"minutes"
),
dateAdd(
now(),
60 - minute,
"minutes"
)
)
)
/* Explained */
let(
/* First, get the minute value of now() and set it as a minute variable */
minute, now().minute(),
if(
/* Check if the minute value is less than 30 */
minute < 30,
/* If so, subtract the minute value from now() to get the current hour */
dateSubtract(
now(),
minute,
"minutes"
),
/* If not, add the minute value to now() to get the next hour */
dateAdd(
now(),
60 - minute,
"minutes"
)
)
)
Code language: JavaScript (javascript)