The HOUR formula in Excel is a function that, as the name suggests, returns the hour of a specified time, ranging from 0 (12:00 AM) to 23 (11:00 PM).
The purpose of the HOUR formula is to extract the hour as a number from a specific time value or time text string. It simplifies data analysis tasks by separating the hour component from full date-time values.
Here’s the basic syntax of the HOUR formula:
The HOUR formula has a single parameter:
- Serial_number: This represents the Excel time from which you want to extract the hour.
The HOUR formula yields an integer that signifies the hour component of a given time.
Remember, the HOUR formula is particularly beneficial when you need to isolate the hour component from a time for data analysis.
Rest assured, you can use the HOUR formula in all versions of Excel.
Let’s say you want to extract the hour from the time 18:30. You would utilize the HOUR formula like this:
The formula will return the number 18, which represents the hour.
Assume you have a time in cell A2 and you wish to determine the hour. Here’s the HOUR formula you would use:
This formula will return the hour component of the time in cell A2.
For this example, let’s extract the hour from the current time:
This formula will yield the current hour.
In our fourth example, let’s calculate the hour from a full date-time string:
This formula will return the number 15, which represents the hour.
In our last example, let’s determine the hour from a time given in 12-hour format:
This formula will return the number 14, which is the equivalent of 2 PM in a 24-hour format.
Tips and tricks
A handy trick when using the HOUR formula in Excel is to remember that it also works with date-time strings and can convert a 12-hour format into a 24-hour format.
The HOUR formula’s key limitation is that it doesn’t recognize text values that aren’t valid times. In such cases, it returns a #VALUE! error.
Common errors and solutions
The most common mistake when using the HOUR formula is inputting non-time values for the serial_number parameter. Ensure that the input values are valid times to avoid a #VALUE! error.
The best practice when using the HOUR formula is always to verify the input times for accuracy.
List of Related functions
HOUR is just one of many date and time functions in Excel. Other related functions include MINUTE, SECOND, NOW, and TIME.
Frequently Used with the formulas
The HOUR formula often pairs with other formulas like NOW, TODAY, MINUTE, and SECOND for more comprehensive time calculations.
Frequently Asked Questions
Q. What happens if the serial_number is not a valid time?
If the serial_number is not a valid time, the HOUR formula will return a #VALUE! error.
Q. Can I use the HOUR formula with date-time strings?
Yes, the HOUR formula can extract the hour from date-time strings.
Q. Can the HOUR formula handle time in 12-hour format?
Yes, the HOUR formula can convert a 12-hour format into a 24-hour format.
Excel’s HOUR formula is a valuable tool for data analysis tasks. With it, you can simplify and accelerate your time-related calculations.
Visit our YouTube channel to learn step-by-step video tutorials