[英]Count Date Values of Current Month - MS Excel
I have following date values (with time) in Column A. 我在A栏中有以下日期值(含时间)。
1/1/2012 8:50
1/1/2012 8:45
1/1/2012 8:55
1/1/2012 8:59
1/1/2012 8:12
3/1/2012 8:30
1/1/2012 9:50
2/1/2012 10:00
Now, I want to get a count of cells from Column A having date values of current Month. 现在,我想从A列获取具有当前月的日期值的单元格计数。
I have thought of following formula, but I suspect it will work only in machines having mm-dd-yyyy as System-Date-Format. 我已经考虑过遵循以下公式,但是我怀疑它只能在具有mm-dd-yyyy作为System-Date-Format的机器中使用。
=COUNTIFS(A:A,">="&DATEVALUE(MONTH(TODAY())&"-1"&"-"&YEAR(TODAY())),A:A,"<"&DATEVALUE(MONTH(TODAY())+1&"-1"&"-"&YEAR(TODAY())))
Any workaround/trick for this? 任何解决方法/技巧?
Try this: =SUM(IF(MONTH(TODAY())=MONTH(A:A),1,0))
, but press CTRL + SHIFT + ENTER instead of usual ENTER - this will define an ARRAY formula and will result in {}
brackets around it (but do NOT type them manually!). 试试这个: =SUM(IF(MONTH(TODAY())=MONTH(A:A),1,0))
,但是按CTRL + SHIFT + ENTER而不是通常的ENTER-这将定义一个ARRAY公式并导致{}
放在方括号中(但不要手动输入!)。
Put the formula in ANY cell you like. 将公式放在您喜欢的任何单元格中。
您可以像这样在当月使用COUNTIFS
=COUNTIFS(A:A,">="&EOMONTH(TODAY(),-1)+1,A:A,"<"&EOMONTH(TODAY(),0)+1)
An alternative to the array formula would be to use SUMPRODUCT()
: 数组公式的替代方法是使用SUMPRODUCT()
:
=SUMPRODUCT(--(MONTH(A:A)=MONTH(TODAY())))
The --
part is necessary: it turns an array of TRUE/FALSE values into numbers. --
部分是必需的:它将TRUE / FALSE值的数组转换为数字。 The double-negative is needed to get a positive value: =VALUE(TRUE)
gives an error, =VALUE(-TRUE)
gives -1
, so =VALUE(--TRUE)
gives +1
. 需要双负数以获得正值: =VALUE(TRUE)
给出错误, =VALUE(-TRUE)
得到-1
,所以=VALUE(--TRUE)
=VALUE(-TRUE)
=VALUE(--TRUE)
得到+1
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.