将持续时间划分为时间段

时间:2018-01-16 16:32:37

标签: excel-2007

我有一个事件开始时间和结束时间,例如Sr = tart时间15/01/2018 11:30和结束时间16/01/2018 02:40在excel表中。

如何将此时间范围拆分为不同的时间段。细分为: -

06:00 - 11:59, 12:00 - 14:59, 15:00 - 17:59, 18:00 - 22:59, 23:00 - 05:59

For 06:00 - 11:59 I would expect 0.50 as this is 30 mins.
For 12:00 - 14:59 I would expect 3.0 for 3 hours. 
For 15:00 - 17:59 I would expect 3.0 for 3 hours again.
For 18:00 - 22:59 this should be 5hrs 
and for 23:00 - 02:40 should be 3.67 hrs.

我需要用什么公式来实现这个目标?

1 个答案:

答案 0 :(得分:0)

对于您给出的布局示例,该公式应如下所示:

df1 %>%
   filter_at(vars(matches("^item\\d+$")), any_vars(.== exact_name))

SO48285831 example

C3中的公式为:

=MIN($D3-F$1,MIN(F$2-F$1,IF($C3<F$2,F$2-$C3+SUM($E3:E3),)))

和D3:

=24*(MOD(A3,1))