HOUR Function Examples – Excel, VBA, & Google Sheets

This tutorial demonstrates how to use the Excel HOUR Function in Excel to get the hour of time.

HOUR Main Function

HOUR Function Overview:

The HOUR Function Returns the hour as a number (0-23).

To use the HOUR Excel Worksheet Function, Select cell and Type:

hour formula syntax

(Notice how the formula input appear)

HOUR Function syntax and Inputs:

serial_number – The time, represented as a fraction of the day or entered as time surrounded by quotations (“s”). Example: You can not enter 8:00:00 pm directly into the cell. Instead you would need to use the corresponding fraction of the day: .3333 or the time surrounded by quorations: “8:00:00 pm”. Alternatively, you can reference a cell with the time entered. Excel automatically converts times stored in cells into a fractional number (unless the time is stored as text).

AutoMacro - VBA Code Generator

HOUR Examples

The HOUR Function returns the hour number of a time:

Hour

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

HOUR in Google Sheets

The HOUR Function works exactly the same in Google Sheets as in Excel:

HOUR Google sheet

 

HOUR Examples in VBA

You can also use the HOUR function in VBA. Type:
application.worksheetfunction.hour(serial_number)

Executing the following VBA statements

will produce the following results

Vba hour function


For the function arguments (serial_number, etc.), you can either enter them directly into the function, or define variables to use instead.

Return to the List of all Functions in Excel

Excel Practice Worksheet

Practice Excel functions and formulas with our 100% free practice worksheets!

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!