HOUR Function Examples – Excel, VBA, & Google Sheets

Written by

Editorial Team

Reviewed by

Steve Rynearson

Last updated on November 6, 2023
Download Example Workbook

Download the example workbook

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

HOUR Main Function

HOUR Examples

The HOUR Function returns the hour number of a time:



HOUR and TIME Functions

Using the TIME and HOUR Functions you can create a new time with the hour number from the original time:



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:


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

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.

AI Formula Generator

Try for Free

Excel Practice Worksheet

practice excel worksheet

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

  • Automatically Graded Exercises
  • Learn Excel, Inside Excel!

Free Download

Return to List of Excel Functions