If you’re someone who frequently works with data and spreadsheets, you know how important it is to have a good understanding of all the functions and tools at your disposal. The HOUR function is a handy one to have in your toolkit, especially if you need to extract the hour portion of a date or time value.

In this post, we’ll take a closer look at what the HOUR function does, how to use it, and some tips for getting the most out of it in your spreadsheet projects. Whether you’re new to Google Sheets or you’re a seasoned pro, we hope you’ll find something useful in this post. So let’s get started!

Table of Contents

## Definition of HOUR Function

The HOUR function in Google Sheets is a built-in function that extracts the hour portion of a time value and returns it as a number. It takes a time value as its input and returns an integer representing the hour of the time value, from 0 to 23. The HOUR function is useful for extracting the hour portion of a time value and performing calculations or comparisons based on the hour. It can be used in a variety of contexts, such as scheduling, time tracking, and data analysis. The HOUR function is commonly used in combination with other functions, such as MINUTE and SECOND, to extract different parts of a time value.

## Syntax of HOUR Function

The syntax of the HOUR function in Google Sheets is as follows:

=HOUR(time_value)

Here, time_value is a required input and should be a time value in Google Sheets, such as a cell reference containing a time or a time entered as text. The time value can be in a variety of formats, including military time (e.g. “17:30:00”) or standard time with an AM/PM indicator (e.g. “5:30 PM”).

Here’s an example of how you might use the HOUR function in a Google Sheets formula:

=HOUR(A1)

This formula would extract the hour portion of the time value in cell A1 and return it as a number.

It’s important to note that the HOUR function only works with time values, not date values. If you want to extract the hour portion of a date and time value, you can use the HOUR function in combination with the TIME function, which allows you to extract the time portion of a date and time value.

=HOUR(TIME(A1))

This formula would extract the hour portion of the date and time value in cell A1 and return it as a number.

## Examples of HOUR Function

Here are three examples of how you might use the HOUR function in Google Sheets:

- Extract the hour portion of a time value and use it in a calculation:

Suppose you have a spreadsheet with a column of time values representing the start times of various events. You want to calculate the duration of each event in hours. You can use the HOUR function to extract the hour portion of the start time and multiply it by the number of hours in an event to get the duration in hours. For example:=HOUR(A1) * B1

This formula would extract the hour portion of the start time in cell A1 and multiply it by the number of hours in the event in cell B1 to get the duration in hours.

- Compare the hour portion of two time values:

Suppose you have a spreadsheet with two columns of time values and you want to compare the hour portion of the time values in each column. You can use the HOUR function in combination with the IF function to compare the hour portion of the time values and return a value based on the result of the comparison. For example:=IF(HOUR(A1) > HOUR(B1), "A is later", "B is later")

This formula would compare the hour portion of the time values in cells A1 and B1 and return “A is later” if the hour in cell A1 is greater than the hour in cell B1, or “B is later” if the hour in cell B1 is greater than the hour in cell A1.

- Extract the hour portion of a time value and format it as text:

Suppose you have a spreadsheet with a column of time values and you want to extract the hour portion of the time values and format it as text. You can use the HOUR function in combination with the TEXT function to extract the hour portion of the time values and format it as text. For example:=TEXT(HOUR(A1), "00")

This formula would extract the hour portion of the time value in cell A1 and format it as text with a leading zero if the hour is less than 10. The result would be a string of text, such as “07” for 7:00 AM.

## Use Case of HOUR Function

Here are three real-life examples of using the HOUR function in Google Sheets:

- Schedule management:

Suppose you have a spreadsheet with a list of appointments and you want to color-code the cells based on the hour of the appointment. You can use the HOUR function in combination with the IF function and the color functions (e.g. FILL, FONT) to color-code the cells based on the hour of the appointment. For example:=IF(HOUR(A1) < 12, FILL(A1, "green"), FILL(A1, "red"))

This formula would fill the cell A1 with green if the hour of the appointment is before 12:00 PM (noon), or red if the hour is 12:00 PM or later.

- Time tracking:

Suppose you have a spreadsheet with a list of tasks and the start and end times for each task. You want to calculate the total number of hours worked on each task. You can use the HOUR function to extract the hour portion of the start and end times and subtract the start time from the end time to get the duration in hours.

For example:=HOUR(B1) - HOUR(A1)

This formula would extract the hour portion of the start time in cell A1 and the end time in cell B1, and subtract the start time from the end time to get the duration in hours.

- Data analysis:

Suppose you have a spreadsheet with a column of date and time values representing the dates and times of various events. You want to extract the hour portion of the date and time values and create a histogram to visualize the distribution of events by hour. You can use the HOUR function to extract the hour portion of the date and time values and the COUNTIF function to count the number of events in each hour. For example:=COUNTIF(HOUR(A:A), 0)

This formula would count the number of events with an hour of 0 (midnight) in the range A:A. You can use a similar formula to count the number of events in each hour and create a histogram to visualize the distribution of events by hour.

## Limitations of HOUR Function

There are a few limitations of the HOUR function in Google Sheets that you should be aware of:

- The HOUR function only works with time values, not date values:

The HOUR function can only extract the hour portion of a time value, not a date value. If you try to use the HOUR function with a date value, it will return an error. To extract the hour portion of a date and time value, you can use the HOUR function in combination with the TIME function, which allows you to extract the time portion of a date and time value. - The HOUR function may not work correctly with certain time formats:

The HOUR function expects the time value to be in a specific format, such as military time (e.g. “17:30:00”) or standard time with an AM/PM indicator (e.g. “5:30 PM”). If the time value is not in one of these formats, the HOUR function may not work correctly. For example, if the time value is in a custom format, such as “5:30”, the HOUR function may return an error or an incorrect result. - The HOUR function may not work correctly with time values that include the time zone:

The HOUR function does not consider the time zone of the time value. If the time value includes the time zone, the HOUR function may return an incorrect result. For example, if the time value is “17:00:00 +02:00” (5:00 PM in the GMT+2 time zone), the HOUR function would return 17, which is the hour in the GMT time zone, not the hour in the GMT+2 time zone. To extract the hour portion of a time value that includes the time zone, you can use the HOUR function in combination with the TIMEVALUE function, which converts a time value with a time zone to a time value in the local time zone.=HOUR(TIMEVALUE(A1))

This formula would extract the hour portion of the time value in cell A1, which includes the time zone, and return it as a number in the local time zone.

## Commonly Used Functions Along With HOUR

Here are some commonly used functions that are often used in combination with the HOUR function in Google Sheets:

- MINUTE function: The MINUTE function is a built-in function in Google Sheets that extracts the minute portion of a time value and returns it as a number. It takes a time value as its input and returns an integer representing the minute of the time value, from 0 to 59. To extract the hour and minute portions of a time value and format them as text, you can use the HOUR and MINUTE functions in combination with the TEXT function. For example:
=TEXT(HOUR(A1), "00") & ":" & TEXT(MINUTE(A1), "00")

This formula would extract the hour and minute portions of the time value in cell A1 and format them as text with leading zeros, separated by a colon. The result would be a string of text, such as “07:30” for 7:30 AM.

- SECOND function: The SECOND function is a built-in function in Google Sheets that extracts the second portion of a time value and returns it as a number. It takes a time value as its input and returns an integer representing the second of the time value, from 0 to 59. To extract the hour, minute, and second portions of a time value and format them as text, you can use the HOUR, MINUTE, and SECOND functions in combination with the TEXT function. For example:
=TEXT(HOUR(A1), "00") & ":" & TEXT(MINUTE(A1), "00") & ":" & TEXT(SECOND(A1), "00")

This formula would extract the hour, minute, and second portions of the time value in cell A1 and format them as text with leading zeros, separated by colons. The result would be a string of text, such as “07:30:00” for 7:30 AM.

- TIME function: The TIME function is a built-in function in Google Sheets that creates a time value from separate hour, minute, and second values. It takes three arguments: the hour, minute, and second values, and returns a time value. To extract the hour portion of a date and time value and return it as a number, you can use the HOUR function in combination with the TIME function. For example:
=HOUR(TIME(A1))

This formula would extract the hour portion of the date and time value in cell A1 and return it as a number.

- IF function: The IF function is a built-in function in Google Sheets that tests a condition and returns one value if the condition is true and another value if the condition is false. It takes three arguments: the condition to test, the value to return if the condition is true, and the value to return if the condition is false. To compare the hour portion of two time values and return a value based on the result of the comparison, you can use the HOUR function in combination with the IF function.

## Summary

In summary, the HOUR function is a useful built-in function in Google Sheets that allows you to extract the hour portion of a time value and return it as a number. It is commonly used in combination with other functions, such as MINUTE and SECOND, to extract different parts of a time value and format them as text. The HOUR function is useful for a variety of purposes, including scheduling, time tracking, and data analysis.

If you’re someone who works with data and spreadsheets, we encourage you to try using the HOUR function in your own Google Sheets projects. Whether you’re new to Google Sheets or you’re a seasoned pro, we hope you’ll find the HOUR function to be a valuable tool in your toolkit. With a little practice, you’ll be able to use the HOUR function to extract the hour portion of time values and use it to your advantage in your spreadsheet projects.

## Video: HOUR Function

In this video, you will see how to use HOUR function. We suggest you to watch the video to understand the usage of HOUR formula.