HOUR Function Examples – Excel, VBA, & Google Sheets
Written by
Reviewed by
Download the example workbook
This tutorial demonstrates how to use the HOUR Function in Excel to get the hour of time.
HOUR Examples
The HOUR Function returns the hour number of a time:
=HOUR(B4)
HOUR and TIME Functions
Using the TIME and HOUR Functions you can create a new time with the hour number from the original time:
=TIME(HOUR(B4),10,10)
HOUR in Google Sheets
The HOUR Function works exactly the same in Google Sheets as in Excel:
HOUR Examples in VBA
You can also use the HOUR function in VBA. Type:
application.worksheetfunction.hour(serial_number)
Executing the following VBA statements
Range("B2") = Hour(Range("A2"))
Range("B3") = Hour(Range("A3"))
Range("B4") = Hour(Range("A4"))
Range("B5") = Hour(Range("A5"))
Range("B6") = Hour(Range("A6"))
Range("B7") = Hour(Range("A7"))
Range("B8") = Hour(Range("A8"))
will produce the following results
For the function arguments (serial_number, etc.), you can either enter them directly into the function, or define variables to use instead.