The HOUR function returns hours from 0 to 23 of the specified time.
This function can be useful when you need to work with individual components of time, for example, to analyze data on an hourly basis.
Syntax
HOUR(time)
Argument |
Description |
Permitted values |
|---|---|---|
time |
The value of time from which the number of hours is retrieved |
Reference to a cell containing a date, a function that returns a date value, a row containing a date or time in a valid format |
Examples of use
Retrieving hours from time in text format
If you have a time entered in cell A1, for example, 14:30, you can retrieve the hours as follows:
=HOUR(A1)
Result: 14.
Use with the current time
You can also use the HOUR function with the NOW function to get the current hour:
=HOUR(NOW)
This formula returns the current hour.
Notes
–The HOUR function returns a value between 0 and 23, where 0 corresponds to midnight and 23 corresponds to the last hour of the day.
–If you want to get minutes, use the MINUTE function.