Example 1
Hour from a time
B2 =HOUR(A2)
Result: 14
Only the hour part is returned. Minutes and seconds are ignored.
B2 =HOUR(A2) returns 14
Returns the hour of a time or timestamp as a whole number from 0 to 23.
Syntax
=HOUR()
All versions of Excel.
Try it
Edit the formula in B2 or change the inputs. The sheet recalculates as you type.
B2 =HOUR(A2) returns 14
HOUR returns the hour part of a time as a whole number between 0 (midnight) and 23 (11 pm). =HOUR(TIME(14,45,0)) returns 14. It ignores minutes and seconds, so 14:01 and 14:59 both return 14. HOUR sits alongside MINUTE and SECOND, which return the other two parts.
serial_number is the time. It can be a time-only value, a date-and-time value such as a timestamp, or text Excel recognises as a time. For a timestamp, HOUR uses only the time fraction and ignores the date. A plain number is read as a fraction of a day, so =HOUR(0.75) is 18, because 0.75 of a day is 6 pm, and a whole number returns 0.
HOUR returns hours, not elapsed hours. A time of 1:30 returns 1, not 1.5. To get decimal hours, work from the fraction of a day: =MOD(A2,1)*24. HOUR also never goes above 23, so it can't report a duration of 30 hours. For durations, subtract two timestamps and multiply by 24 instead of using HOUR on the difference. =HOUR(B2-A2) of an 8 hour 30 minute shift returns 8, and over 24 hours it wraps.
=HOUR(A2) in a helper column and group on it.=IF(AND(HOUR(A2)>=6,HOUR(A2)<18),"Day","Night").=IF(HOUR(A2)<12,"AM","PM").=AND(HOUR(A2)>=9,HOUR(A2)<17).=SUMPRODUCT(--(HOUR(A2:A100)=14)) counts timestamps from 14:00 to 14:59.=FLOOR(A2,1/24) or =INT(A2*24)/24.Text times such as "14:45" work, and so do 12-hour forms with AM or PM: =HOUR("2:45 PM") returns 14. Text that Excel can't read as a time returns #VALUE!. If the data came from an export and the times are text, convert them with TIMEVALUE or VALUE first.
HOUR throws the date away. Two timestamps on different days at the same time of day return the same hour, so group by date as well when you build hourly summaries across days.
"14:45". A decimal such as 0.75 is read as a fraction of a day, which is 6 pm.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
B2 =HOUR(A2)
Result: 14
Only the hour part is returned. Minutes and seconds are ignored.
B2 =HOUR(A2) returns 14
Example 2
B2 =HOUR(A2)
Result: 23
The date part is ignored. 23:59:59 is still in hour 23, so HOUR doesn't round up to midnight.
B2 =HOUR(A2) returns 23
Example 3
B2 =IF(AND(HOUR(A2)>=6,HOUR(A2)<18),"Day","Night")
Result: Night
05:59 is hour 5, which is before 6, so the shift is Night. At 06:00 the hour becomes 6 and the result changes to Day.
B2 =IF(AND(HOUR(A2)>=6,HOUR(A2)<18),"Day","Night") returns Night
Example 4
D2 =SUMPRODUCT(--(HOUR(A2:A6)=14))
Result: 3
HOUR runs on every time at once. The 14:05, 14:48 and 14:59:59 orders return 14, and the 15:00 order doesn't.
D2 =SUMPRODUCT(--(HOUR(A2:A6)=14)) returns 3
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In B2, return the hour (0 to 23) of the clock-in time in A2. Fill it down to B5.
Answer in B2, then it fills down to B5.
MOD(A2,1)*24.HOUR(B2-A2) wraps for gaps of 24 hours or more. Use (B2-A2)*24 for elapsed hours.#VALUE!. Convert them with TIMEVALUE, or check for stray spaces.HOUR(14) returns 0, not 14, because 14 is a whole number of days. To turn 14 hours into a time, use TIME(14,0,0).Use `=HOUR(A2)`. It returns a number from 0 to 23. For a time in 12-hour format such as 2:45 PM, the answer is still 14.
Use `=MOD(A2,1)*24`. For 9:30 it returns 9.5. `=HOUR(A2)+MINUTE(A2)/60` gives the same result.
Excel reads numbers as days. 14 is exactly 14 days with no time part, so the hour is 0. Use `=HOUR(TIME(14,0,0))` or divide: `=HOUR(14/24)`.
Add a helper column with `=HOUR(A2)` and summarise it with COUNTIFS, SUMIFS or a pivot table. Add the date as a second key if the data covers several days.
Tracks take you from the basics to modelling, one graded exercise at a time.