Skip to content

HOUR

Returns the hour of a time or timestamp as a whole number from 0 to 23.

Syntax

=HOUR()

Date and time

All versions of Excel.

Try it

Edit the formula in B2 or change the inputs. The sheet recalculates as you type.

B2
A
B
C
1
Time
Hour
2
2:45 PM
14
3

B2 =HOUR(A2) returns 14

How HOUR works

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.

The one argument

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.

Whole hours only

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.

Common patterns

  • Hour buckets for a heat map or pivot: put =HOUR(A2) in a helper column and group on it.
  • Day or night shift: =IF(AND(HOUR(A2)>=6,HOUR(A2)<18),"Day","Night").
  • Morning or afternoon: =IF(HOUR(A2)<12,"AM","PM").
  • Business hours test: =AND(HOUR(A2)>=9,HOUR(A2)<17).
  • Count events in one hour: =SUMPRODUCT(--(HOUR(A2:A100)=14)) counts timestamps from 14:00 to 14:59.
  • Round a timestamp down to the hour: =FLOOR(A2,1/24) or =INT(A2*24)/24.

Time-of-day text

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 and the date

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.

Arguments

serial_number
The time to read: a cell holding a time or a date-and-time, a value built with TIME, or text Excel reads as a time, such as "14:45". A decimal such as 0.75 is read as a fraction of a day, which is 6 pm.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Hour from a time

B2 =HOUR(A2)

Result: 14

Only the hour part is returned. Minutes and seconds are ignored.

B2
A
B
C
1
Time
Hour
2
2:45 PM
14
3

B2 =HOUR(A2) returns 14

Example 2

Hour from a date-and-time timestamp

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
A
B
C
1
Logged at
Hour
2
15-Mar-2025 23:59:59
23
3

B2 =HOUR(A2) returns 23

Example 3

Day or night shift

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
A
B
C
1
Clocked in
Shift
2
15-Mar-2025 05:59
Night
3

B2 =IF(AND(HOUR(A2)>=6,HOUR(A2)<18),"Day","Night") returns Night

Example 4

Count events in one hour

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
A
B
C
D
1
Order time
Orders 14:00-14:59
2
9:12:00
3
3
14:05:00
4
14:48:00
5
15:00:00
6
14:59:59
7

D2 =SUMPRODUCT(--(HOUR(A2:A6)=14)) returns 3

Your turn.

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.

B2
A
B
C
D
E
1
Clocked in
Hour
Shift
2
15-Mar-2025 14:45
3
15-Mar-2025 22:10
4
16-Mar-2025 05:59
5
16-Mar-2025 06:00
6

Common mistakes

  • HOUR returns whole hours only. 1:30 gives 1, not 1.5. For decimal hours use MOD(A2,1)*24.
  • It never exceeds 23, so it can't report a duration above a day. HOUR(B2-A2) wraps for gaps of 24 hours or more. Use (B2-A2)*24 for elapsed hours.
  • It ignores the date. Timestamps from different days at the same time give the same hour, so combine it with the date when you group by hour.
  • Text times that Excel can't read return #VALUE!. Convert them with TIMEVALUE, or check for stray spaces.
  • A plain number is a fraction of a day. 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).

Questions people ask

How do I get the hour from a time in Excel?

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.

How do I get decimal hours instead of whole hours?

Use `=MOD(A2,1)*24`. For 9:30 it returns 9.5. `=HOUR(A2)+MINUTE(A2)/60` gives the same result.

Why does HOUR return 0 for a number like 14?

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

How do I group a list of timestamps by hour?

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.

Learn HOUR in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.