hour

Learn how to use the hour function in Notion formulas.

This article may contain affiliate links.This article may contain affiliate links.

The hour() function returns an integer (number) between 0 and 23 that corresponds to the hour of its date argument.

hour(date)

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

hour() (and its sibling functions minute, day, date, month, and year) is useful for manipulating dates within Notion formulas.

Copy link to heading
hour(now()) /* Output: 11 (When current time was 11:25 AM) */

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

hour() 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().hour(), "hours")
/* Output: June 24, 2022 12:34 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.

Copy link to heading

This example database groups events in a Renaissance Faire by their time of day – Morning, Afternoon, and Evening. These three options are returned by the Time of Day formula property.

Copy link to heading
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
Copy link to heading
ifs(
	prop("Date").hour() >= 18,
	"πŸŒ” Evening",
	prop("Date").hour() >= 12,
	"🌀 Afternoon",
	"πŸŒ„ Morning"
)
Code language: JavaScript (javascript)

Here, we use a nested if statement to first check if the hour() value of the Date property is greater than or equal to 18 (which is 6:00 PM in 12-hour time).

If yes, the formula returns “πŸŒ” Evening”.

If not, we then check if the hour() value is greater than or equal to 12 (noon in 12-hour time).

If yes, the formula returns “🌀 Afternoon”. If no, it returns “πŸŒ„ Morning”.

From there, we can set the database view to Group by the output of this formula property:

Other formula components used in this example:

if – Thomas Frank
thomasjfrank.com
largerEq – 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