Excel - HOUR Function



HOUR Function

The Excel HOUR function is used to extract the hour component from the given time value or serial number and retrieves an integer number ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.) It is categorized under the Date & Time functions in Excel and consistently used to isolate the HOUR component from the given serial number.

For example, suppose you wish to pinpoint the hours to identify the incidents frequently occurring in a city. In that case, you can use the HOUR function to determine the hours associated with these incidents.

Compatibility

This advanced Excel function is compatible with the following versions of MS-Excel

  • Excel for Microsoft 365
  • Excel for Microsoft 365 for Mac
  • Excel for the web
  • Excel 2024
  • Excel 2024 for Mac
  • Excel 2021
  • Excel 2021 for Mac
  • Excel 2019
  • Excel 2016
  • Excel 2013
  • Excel 2010
  • Excel 2007

Syntax

The syntax of the HOUR function is as follows −

=HOUR(serial_number)

Arguments

You can use the following arguments with the HOUR function −

Argument Description Required / Optional
Serial_number

It specifies a time value from where the hour part will be extracted.

Times may be specified as text strings enclosed within quotation marks, as decimal numbers, or as results of other formulas or functions.

Required

Points to Remember

  • Time values are a part of a date and are denoted by a decimal point number.
  • If the invalid time or date is specified in the Serial_number argument, then the HOUR function will retrieve the #VALUE! Error.
  • If the serial_number contains a negative value, then the HOUR function will return the #NUM! error.
  • You may also fetch the hour component from the time specified as a text string by merging the TIMEVALUE with the HOUR function.

Examples of HOUR Function in Excel

Practice the following examples to learn the use of the HOUR function in Excel.

Example 1: How does the HOUR Function do in Excel?

In this example, we will insert the HOUR function in the cell range C2:C5 by passing different serial numbers as arguments to get an accurate result.

Solution

Step 1 − First, consider the sample dataset consist of the Number and Hour columns.

Examples of the HOUR Function in Excel1

Step 2 − After that, you may select the cell range C2:C5 and write the formula =HOUR(B2) in the formula bar.

Examples of the HOUR Function in Excel2

Then, press "Ctrl+Enter" to compute the HOUR() function in the selected range of the cell.

Examples of the HOUR Function in Excel3

Example 2

If the invalid time or date is specified in the Serial_number argument, then the HOUR function will retrieve the #VALUE! Error.

Solution

First, you may switch to "example 2" worksheet and enter the formula =HOUR("12:xx:76") in the B2 cell.

Examples of the HOUR Function in Excel4

After that, hit the Enter tab to get the resulting value.

Examples of the HOUR Function in Excel5

Example 3

If the serial_number contains a negative value, then the HOUR function will return the #NUM! error.

Solution

First, navigate to the "example 3" worksheet, write the formula =HOUR(-89) in the B2 cell, and hit the Enter tab. Here, the negative value is specified in its argument, which leads to an error value when executing this function.

Examples of the HOUR Function in Excel6

Examples of the HOUR Function in Excel7

Note − You may set the valid time value in the serial number to obtain a valid result.

Download Practice Sheet

You can download and use the sample data sheet to practice the HOUR function.

Advertisements