Hour of the day excel

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less

This article describes the formula syntax and usage of the HOUR function in Microsoft Excel.

Description

Returns the hour of a time value. The hour is given as an integer, ranging from 0 (12:00 A.M.) to 23 (11:00 P.M.).

Syntax

HOUR(serial_number)

The HOUR function syntax has the following arguments:

  • Serial_number    Required. The time that contains the hour you want to find. Times may be entered as text strings within quotation marks (for example, «6:45 PM»), as decimal numbers (for example, 0.78125, which represents 6:45 PM), or as results of other formulas or functions (for example, TIMEVALUE(«6:45 PM»)).

Remark

Time values are a portion of a date value and represented by a decimal number (for example, 12:00 PM is represented as 0.5 because it is half of a day).

Example

Copy the example data in the following table, and paste it in cell A1 of a new Excel worksheet. For formulas to show results, select them, press F2, and then press Enter. If you need to, you can adjust the column widths to see all the data.

Time

0.75

7/18/2011 7:45

4/21/2012

Formula

Description

Result

=HOUR(A2)

Returns 75% of 24 hours

18

=HOUR(A3)

Returns the hour portion of the date/time value.

7

=HOUR(A4)

A date with no time portion specified is considered 12:00 AM, or 0 hours.

0

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

Excel defaults to date and time functions: HOUR, MINUTE and SECOND. Consider in detail these three functions in action on specific examples. How, when and where they can be effectively applied, making up various formulas from these functions for working with time.



Examples of using the functions HOUR, MINUTE and SECOND for calculations in Excel

The HOUR function in Excel is designed to determine the hour value from the transmitted time as a parameter and returns data from a range of numeric values from 0 to 23, depending on the format of the temporary record.

The function MINUTE in Excel is used to get the minutes from the transmitted data, which characterizes the time, and returns data from a range of numeric values from 0 to 59.

The SECOND function in Excel is used to get the seconds from data in a time format and returns numeric values from 0 to 59.



Monitoring the daily time clock in Excel using the HOUR function

Example 1. Get the current time, determine how many hours have passed since the beginning of the current day, how many hours left before the beginning of a new day.

Source table:

Example 1.

Let’s define the current moment in the Excel time code:

define the current moment.

Calculate the number of hours from the beginning of the day:

number of hours.

  • B2 — the current date and time, expressed in the format Date.

Determine the number of hours before the end of the day:

hours before end.

Argument Description:

  • 24 — the number of hours per day;
  • B3 is the current time in hours, expressed as a numerical value.

Note: The example demonstrates that the result of the work of the HOUR function is a number on which you can perform any arithmetic operation.

Conversion of numbers to time format using the functions HOUR and MINUTE

Example 2. From the application, moments of passing certain events that were recognized by Excel as ordinary numbers were loaded (for example, 13:05 was recognized as the number 1305). It is necessary to convert the obtained values into the time format, select the hours and minutes.

Source data table:

Example 2.

To convert the data, use the function:

TEXT.

=TEXT(B3,»00:00″)

Argument Description:

  • B3 — the value recognized by Excel as a normal number;
  • «00:00» is the time format.

As a result, we get:

result.

Using the functions HOUR and MINUTE, select the desired values. Similarly, we define the required values for the remaining events:

HOUR and MINUTE.

Example of using the SECOND function in Excel

Example 3. The work day starts at 8:00 am. One worker was systematically late for the previous 10 working days for a few seconds. Determine the total time the employee is late.

Enter the data in the table:

Example 3.

Determine the delay in seconds. Where B3 — data on the time of arrival at work on the first day. Similarly, we define the seconds of delay for the following days:

using the SECOND function.

Determine the total number of seconds of delay:

total number of seconds.

Where C3:C12 is an array of cells containing seconds of late values. We define the integer value of the minutes of delay, knowing that in 1 min = 60 seconds. As a result, we get:

late values.

That is, the total lateness of an employee for 10 days was 263 seconds, which is more than 4 minutes.

Features syntax functions HOUR, MINUTE and SECOND in Excel

The HOUR function has the following syntax entry:

=HOUR(serial_number)

  • serial_number is the only function argument (required) that characterizes time data that contains data about the clock.

Notes:

  1. If a string with text that does not contain time information is passed as an argument to the HOUR function, the error code #VAL! Will be returned.
  2. If the logical data type (TRUE, FALSE) or a reference to an empty cell was passed as an argument to the HOUR function, the value 0 will be returned.
  3. There are several permitted data formats that the HOUR function accepts:
  • In Excel time code (range of values from 0 to 2958465), while the integers correspond to days, fractional — hours, minutes and seconds. For example, 43284.5 is the number of days elapsed between the current moment and the starting point of reference in Excel (01/01/1900 is a conditional date). Fractional part 0.5 corresponds to 12 hours (half of the day).
  • In the form of a text string, for example =HOUR(“11:57”). The result of the function — the number 11.
  • In the format of the Date and Time Excel. For example, the function will return the values of the clock if, as an argument, it receives a reference to the cell containing the value “07/03/18 11:24” in the date format.
  • As a result of the function that returns data in a time format. For example, the function =HOUR(TIMEVALUE(“1:34”)) returns the value 1.

The MINUTE function has the following syntax:

=MINUTE(serial_number)

  • serial_number is a required argument describing the value from which the minutes will be calculated.

Notes:

  1. As in the case of the HOUR function, the MINUTE function accepts text and numeric data in the format of Dates and Times.
  2. If the argument of this function is an empty text string (“”) or a string containing text (“some text”), the error #VALUE! Will be returned.
  3. The function supports date format in Excel time code (for example, =MINUTE(0.34) returns the value 9).

The syntax of the SECOND function in Excel is:

=SECOND(serial_number)

  • serial_number is the only argument represented as data from which the seconds will be calculated (required for filling).

Download examples HOUR, MINUTE and SECOND to work with time in Excel

Notes:

  1. The SECOND function works with text and numeric data types representing Date and Time in Excel.
  2. Error #VALUE! will occur in cases where the argument is a text string that does not contain data characterizing the time.
  3. The function also calculates seconds from the number represented in the Excel time code (for example, =SECOND(9,567) returns the value 29).

Please Note:
This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Determining the Hour of the Day.

Written by Allen Wyatt (last updated October 22, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003


If you are writing macros for Excel, you may have a need to determine the hour represented by a particular date and time value. For instance, you might want to know the hour of the day in which the macro is running. You can ascertain this information by using the HOUR function, as follows:

iThisHour = Hour(Now())

When executed, iThisHour will be equal to the current hour number, which ranges from 0 to 23. Notice that this example uses the Now() function. If you want to determine the hour number for a different date and time value, simply substitute that value in place of the Now() function.

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I’ve prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training.
This tip (2551) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Determining the Hour of the Day.

Author Bio

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. Learn more about Allen…

MORE FROM ALLEN

Backwards Date Parsing

Enter information into a worksheet, and you come to anticipate (and count on) how Excel will interpret that information …

Discover More

Hiding and Protecting Columns

Want to hide certain columns within a worksheet so the contents are not visible to others? The answer lies in formatting …

Discover More

Printing More than One Copy

Need to print more than a single copy of a worksheet? You can do it easily by using the printing controls provided by Excel.

Discover More

More ExcelTips (menu)

Displaying Messages When Automatic Data Changes

It is possible to develop macros that update the information in your worksheets automatically. In such instances, you may …

Discover More

Saving a Workbook in a Macro

Does your macro need to make sure that the workbook being processed is saved to disk? You can add the saving capability …

Discover More

Macros in Template Files

People often place macros in template files to perform any number of tasks. This tip describes a situation where the link …

Discover More

Year, Month, Day | Date Function | Current Date & Time | Hour, Minute, Second | Time Function

To enter a date in Excel, use the «/» or «-» characters. To enter a time, use the «:» (colon). You can also enter a date and a time in one cell.

Date and Time in Excel

Note: Dates are in US Format. Months first, Days second. This type of format depends on your windows regional settings. Learn more about Date and Time formats.

Year, Month, Day

To get the year of a date, use the YEAR function.

Year Function

Note: use the MONTH and DAY function to get the month and day of a date.

Date Function

1. To add a number of days to a date, use the following simple formula.

Add Days

2. To add a number of years, months and/or days, use the DATE function.

Add Years, Months and Days

Note: the DATE function accepts three arguments: year, month and day. Excel knows that 6 + 2 = 8 = August has 31 days and rolls over to the next month (23 August + 9 days = 1 September).

Current Date & Time

To get the current date and time, use the NOW function.

Now Function

Note: use the TODAY function to enter today’s date in Excel.

Hour, Minute, Second

To return the hour, use the HOUR function.

Hour Function

Note: use the MINUTE and SECOND function to return the minute and second.

Time Function

To add a number of hours, minutes and/or seconds, use the TIME function.

Add Hours, Minutes and Seconds

Note: Excel adds 2 hours, 10 + 1 = 11 minutes and 70 — 60 = 10 seconds.

Понравилась статья? Поделить с друзьями:
  • Hour and minutes in excel
  • How do i write a formula in excel
  • Hottest pepper in the word
  • Hottest girl in word
  • How do i use word on my computer