[英]EXCEL - IF Statement for TIME between Ranges
Im using PivotTables and PivotCharts for a Dynamic Dashboard in Excel. 我使用数据透视表和数据透视图在Excel中的动态仪表板。 Currently i have 3 shifts at work that i'd like to visualize but for that to happen i must: 目前我有三个工作班,我想要想象,但为了实现这一点,我必须:
Extract the time from a "Date & Time Cell" which im doing by using =A2 - INT(A2) . 从“日期和时间单元”中提取时间,即使用= A2 - INT(A2)进行操作 。 No problem here 这里没问题
Create a nested IF AND formula to check whether the hour fits in any of theses shifts: 创建一个嵌套的IF AND公式,以检查小时是否适合任何这些班次:
15:00 - 23:00 , 23:00 - 7:00 , 7:00 - 15:00 15:00-23:00,23:00-7:00,7:00-15:00
Im using this: 我用这个:
=IF(AND(E2>=TIME(15,0,0),E2<TIME(23,0,0)),"3-
11",IF(AND(E2>=TIME(23,0,0),E2<TIME(7,0,0)),"11 - 7","7 - 3"))
But it mixes up the shifts, its showing only 3-11 & 7-3 shifts, as if it couldn't distinguish between am and pm... im missing the 23:00 - 7:00 shift 但它混合了轮班,它只显示3-11和7-3班次,好像它无法区分上午和下午...我错过了23:00 - 7:00班次
From the TIME
documentation : 从TIME
文档 :
The decimal number returned by
TIME
is a value ranging from 0 (zero) to 0.99988426, representing the times from 0:00:00 (12:00:00 AM) to 23:59:59 (11:59:59 PM)TIME
返回的十进制数是一个从0(零)到0.99988426的值,表示从0:00:00(12:00:00 AM)到23:59:59(11:59:59 PM)的时间
In other words, AND(E2>=TIME(23,0,0),E2<TIME(7,0,0)
is equivalent (rounded to 2 decimal places) to AND(E2>=0.96,E2<0.29)
. So your second AND
formula can only be false. 换句话说, AND(E2>=TIME(23,0,0),E2<TIME(7,0,0)
等于(舍入到2个小数位)到AND(E2>=0.96,E2<0.29)
。所以你的第二个AND
公式只能是假的。
Either change that AND
to OR
, or flip your 2nd IF
logic around: 要么将AND
更改为OR
,要么将第二个IF
逻辑翻转为:
...IF(AND(E2>=TIME(7,0,0),E2<TIME(15,0,0)),"7 - 3","11 - 7")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.