How to use the HOUR function
What is the HOUR function?
The HOUR function returns an integer representing the hour of an Excel time value. The returning number is ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).
What is an integer?
An integer is a whole number that can be positive, negative, or zero, but not a fraction or decimal. Excel can't calculate the hour based on negative integers.
What is an Excel time value?
Excel time is actually a decimal number ranging between 0 and 1 in Excel and then formatted as time.
For example, 12:00 PM is represented as 0.5 because it is half of a day, you can verify this by typing 12:00 PM in a cell and then change the cell formatting to general. This will show the value as Excel interprets it.
How does Excel recognize time values?
Excel recognizes certain text strings like "6:45 PM" as valid time values. A recognized time value is right aligned in the cell just like a regular number, shown in the image below in cell B2.
A time number that is not recognized is left aligned which is demonstrated in cell B4 in the image above. This visual feedback lets you easily spot values that need closer inspection.
What is an hour in an Excel time value?
1/24 or approx. 0.04166667 represents one hour in Excel time value. Excel uses a number 0 <= x <=Â 1 in decimal form to represent time in a worksheet. 0 is zero hours and 1 is 24 hours. To get one hour we must divide 1 by 24 and we get 1/24.
Why is 1 equal to 24 hours?
This has to do how Excel handles dates. Each date is represented by an integer and one day is 1 in Excel.
Dates are stored numerically but formatted to display in human-readable date/time formats, this enables Excel to do work with dates in calculations.
For example, dates are stored as sequential serial numbers with 1 being January 1, 1900 by default. The integer part (whole number) represents the date the decimal part represents the time.
This allows dates to easily be formatted to display in many date/time formats like mm/dd/yyyy, dd/mm/yyyy and so on and still be part of calculations as long as the date is stored numerically in a cell.
You can try this yourself, type 10000 in a cell, press CTRL + 1 and change the cell's formatting to date, press with left mouse button on OK. The cell now shows 5/18/1927.
What is the decimal form?
The decimal form or decimal number system represents values using digits 0-9 and a decimal point. Each digit position represents a power of 10 - units, tens, hundreds, etc. The decimal point separates the integer part from the fractional part. Decimal values allow representation of fractional numbers in a standard notation.
Where is AM/PM used?
AM/PM is used in the United States, Canada, Mexico, Australia, United Kingdom and a few other countries. AM refers to times from midnight to noon. PM refers to times from noon to midnight.
Where is the 24 hour clock used?
The 24 hour clock is used in continental Europe including Scandinavia, China, India and most countries except those above. Used in formal documents like schedules, timetables, business contracts. Used by scientists, aviation, hospitals, transportation services, military. Avoids AM/PM ambiguity and potential confusion.
AM/PM | 24 hour clock |
12:00 AM | 0:00 |
1:00 AM | 1:00 |
2:00 AM | 2:00 |
3:00 AM | 3:00 |
4:00 AM | 4:00 |
5:00 AM | 5:00 |
6:00 AM | 6:00 |
7:00 AM | 7:00 |
8:00 AM | 8:00 |
9:00 AM | 9:00 |
10:00 AM | 10:00 |
11:00 AM | 11:00 |
12:00 PM | 12:00 |
1:00 PM | 13:00 |
2:00 PM | 14:00 |
3:00 PM | 15:00 |
4:00 PM | 16:00 |
5:00 PM | 17:00 |
6:00 PM | 18:00 |
7:00 PM | 19:00 |
8:00 PM | 20:00 |
9:00 PM | 21:00 |
10:00 PM | 22:00 |
11:00 PM | 23:00 |
12:00 AM | 0:00 |
HOUR function Syntax
HOUR(serial_number)
HOUR function Arguments
serial_number | Required. An Excel time value that you want to calculate the hour of. |
HOUR function example
This example demonstrates the HOUR function in cell C3, it extracts the hour from the Excel time value specified in cell B3: "1:34:22 PM"
Formula in cell C3:
1:00 PM represents the 13th hour.
HOUR function not working
The HOUR function returns #NUM! error if the decimal is a negative value.
The HOUR function returns #VALUE! error if the Excel time value is invalid.
HOUR function alternative - cell formatting
You also have the option to format a cell containing an Excel time value so it shows only the hour part. Here is how:
- Select the cell.
- Press CTRL + 1 to open the "Format Cells" dialog box.
- Select category: Custom
- Create a new type: hh
- Press the "OK" button.
The image above shows cell B3 containing the following time value "1:34:22 PM", cell C3 references that value. This means that cell C3 contains the same value, however, cell formatting is applied which makes it show only the hour part.
'HOUR' function examples
The formula in cell D5 calculates the number of complete hours between the time entries in cell B5 and C5. […]
The DATEDIF function in cell E3 allows you to calculate days between two dates. =DATEDIF(B3,C3,"d") The function is hidden in […]
Table of Contents How to AVERAGE time How to enter an array formula Explaining formula How to AVERAGE time hh […]
Functions in 'Date and Time' category
The HOUR function function is one of many functions in the 'Date and Time' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form