简体   繁体   English

两个日期之间的 Excel COUNTIFS 不断返回 0

[英]Excel COUNTIFS between two dates keep returning 0

I don't understand my formula output (output = 0)我不明白我的公式输出(输出 = 0)

=COUNTIFS(PROJET!$C$13:$C$29,">="&PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11,PROJET!$D$13:$D$29,"<"&PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11)

where在哪里

PLANNING!$B13 = 1
PLANNING!C$12 = June
PLANNING!$I$11 = 2022


PROJET!$C$13:$C$29 = 
17/05/2022
16/12/2022
17/05/2022
19/05/2022
01/06/2022
19/12/2022
17/05/2022
10/11/2022
01/09/2022
15/09/2022
01/12/2022
01/11/2022
05/12/2022
15/12/2022
19/12/2022
16/12/2022
19/12/2022

PROJET!$D$13:$D$29 = 
17/05/2022
16/12/2022
19/05/2022
19/06/2022
01/07/2022
26/12/2022
01/07/2022
11/11/2022
15/09/2022
15/11/2022
09/12/2022
01/11/2022
15/12/2022
16/12/2022
21/12/2022
16/12/2022
29/12/2022

I tried to replace我试图更换

PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11

with :和 :

DATEVAL($B13&"/"&$C$12&"/"&I$11)

but this still return 0 why does this return 0 and not 3 ?但这仍然返回 0 为什么返回 0 而不是 3 ? what am I missing ?我错过了什么? I highlight in red the date where the date is between (01/06/2022)我用红色突出显示日期之间的日期 (01/06/2022) 在此处输入图片说明

Your date criteria is not a date.您的日期标准不是日期。 But even when you convert it to a date (using DATEVAL which I assume is the same as the US English DATEVALUE ), You will still return 0 because you have no rows that match both conditions of C >= 1/jun/2022 and D<1/jun/2022但是,即使您将其转换为日期(使用DATEVAL ,我认为它与美国英语DATEVALUE相同),您仍然会返回0因为您没有符合C >= 1/jun/2022D<1/jun/2022

To get a result of 3, you could change your comparisons around:要获得 3 的结果,您可以更改您的比较:

=COUNTIFS(PROJET!$C$13:$C$29,"<="&DATEVALUE(PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11),
          PROJET!$D$13:$D$29,">"&DATEVALUE(PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11))

在此处输入图片说明

Of course, I don't know if that's what you really want.当然,我不知道这是否是你真正想要的。

I think the way you are defining dates doesn't work.我认为您定义日期的方式不起作用。 You can't paste together "1" "/" "June" and "2022" and have excel compare that to a date, unless I'm totally misunderstanding what you're trying to do.您不能将“1”“/”“June”和“2022”粘贴在一起并让excel将其与日期进行比较,除非我完全误解了您要做什么。 Here's an a simple example I cooked up:这是我编写的一个简单示例:

Sample Criteria样本标准

With Formula showing随着公式显示

The #1 there calculates the number of dates in between 4/1/2021, and 3/1/2021.那里的 #1 计算 4/1/2021 和 3/1/2021 之间的日期数。 The formula I used was this: =COUNTIFS(B12:B15,"<="&DATE(2021,3,1),B12:B15,">"&DATE(2021,2,1))我使用的公式是这样的:=COUNTIFS(B12:B15,"<="&DATE(2021,3,1),B12:B15,">"&DATE(2021,2,1))

Basically, I think where you're going wrong is you're telling excel to compare "1/June/2022" as a STRING to the date format 1/June/2022.基本上,我认为你出错的地方是你告诉 excel 将“1/June/2022”作为字符串与日期格式 1/June/2022 进行比较。 Hopefully that helps, try using the date function instead of what you have.希望这会有所帮助,请尝试使用日期函数而不是您拥有的函数。 So instead of this: ">="&PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11,PROJET!$D$13:$D$29,所以不是这个: ">="&PLANNING!$B13&"/"&PLANNING!C$12&"/"&PLANNING!$I$11,PROJET!$D$13:$D$29,

Try this试试这个

">=DATE(Planning!B13, PlanningC12, PlanningI11)" ">=日期(计划!B13,PlanningC12,PlanningI11)”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM