
The HOUR function in Excel is used to extract the hour component from a time value. It returns an integer between 0 and 23, where 0 represents 12:00 AM and 23 represents 11:00 PM. Here’s how to use the HOUR function:
Syntax
HOUR(serial_number)
- serial_number: This is the time from which you want to extract the hour. It can be a cell reference, a date-time string, or a time value.
Examples
- Extracting the Hour from a Time Value in a Cell:
- Suppose cell A1 contains the time “02:30 PM”.
- Use the formula `=HOUR(A1)` to get the result `14`.
- Using the HOUR Function with a Date and Time:
- If cell B1 has “12/10/2023 07:45:00 AM”, using `=HOUR(B1)` will return `7`.
- Using a Direct Time String:
- You can use a direct string like `=HOUR(“16:45”)`, and it will return `16`.
- Extracting Hour from NOW or CURRENT Time:
- To get the current hour, you could use `=HOUR(NOW())`, which will return the current hour based on your system clock.
Things to Keep in Mind
- If the time value is not recognized by Excel as a valid time, the HOUR function will return an error.
- The date portion in date-time values does not affect the result of the HOUR function; it only focuses on time.
- Ensure that your time values are indeed formatted as time; otherwise, Excel might not interpret them correctly.
Use this function whenever you need to extract or manipulate the hour component from a given time or date-time value in Excel.