# hour

Learn how to use the hour function in Notion formulas.

1

hour(date)

1

hour(now()) // Output: 11 (When current time was 11:25 AM)

2

3

// Assume a propety called Date with a current date of June 24, 2022 11:29 AM

4

hour(prop("Date")) // Output: 11

`hour()`

can be used with other functions such as dateSubtract to change the value of a date, like so:1

// Assume the value of now() is June 24, 2022 11:34 AM

2

dateSubtract(now(), hour(now()), "hours")

3

// Output: June 24, 2022 12:34 AM

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 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.

1

// Compressed

2

if(hour(prop("Date")) >= 18, "🌔 Evening", if(hour(prop("Date")) >= 12, "🌤 Afternoon", "🌄 Morning"))

3

4

// Expanded

5

if(

6

hour(

7

prop("Date")

8

) >= 18,

9

"🌔 Evening",

10

if(

11

hour(

12

prop("Date")

13

) >= 12,

14

"🌤 Afternoon",

15

"🌄 Morning"

16

)

17

)

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:

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.

Last modified 4mo ago