The HOUR function extracts the hour value from a time as a number from 1 to 12.
If you work with times but only care about the hours, this function lets you get rid of everything else. Remember that dates are just numbers with date formatting applied. This function is often used inside formulas with other functions such as the DATE function.
The HOUR function returns the value of the hour from any given unit of time.
#VALUE! – The value passed to the function was not a valid time.
#ERROR! – Formula parse error. The input to the function could not be used, such as a time with no quotes. –
5pm should be
#NUM! – The result was not a number, or the number is too large to resolve to a time.
The output is an unexpected format, such as 12:00 AM. – This means the formatting is incorrect, not the underlying number.
TIMEDIF – Google Sheets Add-On
Calculate any duration in:
Example 1 – Simple HOUR Function
First, we will look at easy examples.
|Extract the hour value from 3:31 am||3|
|Extract the hour value from 3:31 pm||15|
Tip: Notice that the HOUR function adds twelve hours to denote PM.
Example 2 – Separating the Values of a Date and Time
Different date values examined using various functions.
|Time value||Tickmark||YEAR||MONTH||DAY||HOUR||MINUTE||SECOND||Formatted as number|
|6/1/2017 2:32 PM||3||2017||6||1||14||32||0||42,887.61|
|July 31, 2016||4||2016||7||31||0||0||0||42,582.00|
- 1 A random date typed in using slashes.
- 2 A random date typed in using dashes. Note that it is processed the same way as the date with slashes.
- 3 Typed a random date in and added a time. Now the function extracts the hours and minutes.
- 4 Typed in a date but spelled out. Writing out the date also works, but it won’t work if you write the day as “31st” instead of 31.
- 5 If you only type in a time, the “zero” date is 12/30/1899.
- 6 Entered with the NOW function. The output will constantly change in the linked Google Sheet.
- 7 Entered with the TODAY function. The output will change daily in the linked Google Sheet.
- 8 A blank cell is December 30, 1899. Similar to tickmark 5.
- 9 Typing a 1 will increment the value in number 10 above by 1 day. In other words, “1=12/31/1899”. It is just a matter of how it is displayed, which can be controlled by going to the Format menu and choosing Number.
- 10 Just a decimal with no whole number increments the value by hours, minutes, and seconds instead of days.
- 11 To get near the current date, you need to start with 43,000 days away from 12/30/1899.
Live Examples in Sheets
Go to this spreadsheet for examples of the functions shown above that you can study and use anywhere you would like.