简体   繁体   English

Excel 计算日期和年份

[英]Excel Count Day and Year

In my spreadsheet I have a column that contains a date/time.在我的电子表格中,我有一列包含日期/时间。

I have one field where I am counting the number of Monday's that appear in this column, but also want to create a separate count by year.我有一个字段,我正在计算此列中出现的星期一的数量,但还想按年份创建单独的计数。 My current formula is:我现在的公式是:

 =SUM(--(WEEKDAY(D1:D1353)=2))

How would I alter this so that in the same cells D1:D1353 I can narrow it down so that I am counting the number of times a Monday occurred in, say, 2008?我将如何更改它以便在相同的单元格D1:D1353我可以缩小范围,以便我计算星期一发生的次数,例如,2008 年? or 2009?还是2009年?

First, I am assuming this is an array formula entered with CTL + SHIFT + ENTER .首先,我假设这是一个使用CTL + SHIFT + ENTER输入的数组公式。 If that's the case, you should be able to add criteria with multiplication:如果是这种情况,您应该能够添加乘法条件:

{=SUM(--(WEEKDAY(D1:D1353)=2)*(YEAR(D1:D1353)=2008))}


Note: If you multiply * boolean values, this is "equivalent" to having AND conditions between your statements.注意:如果您乘以*布尔值,这“等效于”在您的语句之间具有AND条件。 If you wish to use OR logic, you can use addition + .如果你想使用OR逻辑,你可以使用加法+ For example, the same formula with addition + :例如,相同的公式与加法+

{=SUM(--(WEEKDAY(D1:D1353)=2)+(YEAR(D1:D1353)=2008))}

Would translate to: Give me all dates in range D1:D1353 that are Monday's or dates in range D1:D1353 equal to 2008.将转换为:给我D1:D1353范围内的所有星期一日期D1:D1353范围内等于 2008 的日期。

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

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