小时功能

Categorized as a Date and Time function that returns the hour component of the time

It's amazing howAmazonfulfills its customers' orders exactly on time. Everything from ordering the product to its delivery depends on the timing. If the timing is wrong, the customer can potentially face a delay in the product's delivery.

如何Amazon manages its仓库供应并将产品交付给客户很复杂。例如,如果我们说产品需要一天到达最近的仓库和两个小时才能进行交付,那么我们可以使用小时功能将所有类似产品俱乐部添加到一个列表中。

The function is categorized as a Date andTime functionthat returns the hour component of the time between 0 (12:00 A.M.) and 23 (11:59 P.M.), depending on the时间值用作输入。

Returning to our Amazon example, suppose that 100 products are ordered from NYC between 9 - 10 P.M. on the 4th of April 2022. Using this function, all these deliveries could be clubbed together with their expected delivery time at 9:00 P.M. the next day.

If the delivery time is 9:00 P.M., all 100 products must reach the warehouse by 7:00 P.M.

By maintaining a strict schedule for the supply chain, potential losses could be avoided, and customer satisfaction could be improved - all with a simple time function such as HOUR.

小时功能的语法

The syntax for the function is:

=小时(serial_number)

where,

serial_number=(要求)我们想要的时间价值extract the hour component.

This is a required argument that even accepts time as text strings (for example, "10:30 A.M.") or decimal values (such as 0.84375, which corresponds to 8:15 P.M.).

Example

To understand the function better, we will see different instances of time from which you can extract the hour component.

下面的插图是各种格式,您通常会在Excel中遇到时间。

Example

要在B列中找到每个值的小时组件,请使用公式=小时(B4)并将其拖到最后一个单元格,这将为您带来结果:

试验t

解释

  • 对于日期和时间4/10/2022 23:28,该功能忽略了日期和分钟,仅返回单元C4中的小时,即23。
  • For time 12:00 P.M., the function returns 12.
  • 在时间11:28的时间,该功能将结果返回为23。即使我们的时间为11的小时,也请记住,该数字是根据24小时时钟(0-23)提取的。
  • Well, this is something new. By using the HOUR function on 1.88, we get the result of 21. Let's interpret 1 as a 24 hour period i.e 1 = 24 hours. But the value we have is more than 1, meaning the time is more than 24 hours.

如果我们将1.88的格式更改为[H]:MM:SS,我们会发现我们得到的时间是45:07:12。

解释

但是我们也没有将结果视为45。问题是,一旦完成23:59,时钟再次重置为零。

By subtracting 24:00:00 from 45:07:12, we get the result as 21:07:12, the same result for our hour component.

  • 同样,一个类似的时间,但现在不到24小时(24小时的值为1)。为此,我们得到10。您总是可以通过将值的格式更改为[h]:mm:ss,通过在键盘上使用ctrl + 1键
  • 接下来,我们在单元B9中只有04/10/2022的日期。如果我们没有任何指定的时间,Excel的默认时间为上午12:00。

众所周知,Excel仅从上午12:00返回0-23的数字。到晚上11:59时间,因此我们在Excel中获得的结果为零。

  • 当时间以HH:MM:SS格式(例如15:00:28)表示时,小时函数忽略了分钟和秒,仅将值返回为15。
  • This is similar to what we saw earlier; if the time is 105:28:35, we need to subtract multiples of 24:00:00 to get the present time. The time 105:28:35 could also be interpreted as 4 days, 9 hours, 28 minutes, and 35 seconds.

因此,该函数提取9,我们在细胞C11中的结果。

Practical Example #1

假设您一日游谋生。您交易自己喜欢的股票,Microsoft,,,,Netflix,,,,and特斯拉. You prepare an Excel sheet to record all your transactions so you can better understand how profitable you have been.

假设数据如下:

假设您想知道从一天开始时每小时赚取多少利润。为此,您将使用该公式为=小时(b3)。

This will give you the result as illustrated below:

现在,我们如何以唯一格式表示重复的数据?枢轴!当您进行数据分析时,没有什么比删除重复项的枢轴的比例。
We will only add the 'Profit' and 'Hour' to thePivot Tablefield area. This will return the following table:

Pivot Table

这使我们对利润的分析非常简单。如您所见,最多的利润是在下午2点之间在市场结束阶段赚取的。下午4点

Practical Example #2

One of the applications where the rules of the function are applied is the biometric fingerprint attendance system.

Assume that at the end of the month, you receive the sheet for all the employee ins and outs and need to check whether the employees have completed the necessary working hours in the office (just an example! We hope the working conditions should never be so severe that it takes the fun out of work).

The data is illustrated below:

Example 2

The column' Time spent in the office in Hrs' represents how many hours the employees worked extra or fell short. In columns F and G, we used the formula =HOUR(D4) and =HOUR(E4), respectively.

So, remember, the next time you walk out that door early, you are being watched!

重要的事情要记住:

  • If you do not input a valid Excel time as theserial_numberargument, the function will give you the #VALUE! Error. Decimal values are also excluded from the errors, where the range of 24-hour clock is represented between 0 and 1.
Excel建模课程

Everything You Need To Master Excel Modeling

为了帮助您在华尔街最负盛名的工作中蓬勃发展。

2ManBetX登陆

Researched and Authored by Akash Bagul|LinkedIn

Reviewed and edited by James Fazeli-Sinaki|LinkedIn

Free Resources

To continue learning and advancing your career, check out these additional helpfulWSOresources: