[英]Excel count days per month between two dates using both months and years
I would like to know how to calculate days of each month between two dates:我想知道如何计算两个日期之间每个月的天数:
A![]() |
B![]() |
C ![]() |
D ![]() |
E![]() |
F ![]() |
G ![]() |
|
---|---|---|---|---|---|---|---|
1 ![]() |
From![]() |
To![]() |
01/12/20 ![]() |
01/01/21 ![]() |
01/02/21 ![]() |
01/03/21 ![]() |
01/04/21 ![]() |
:-- ![]() |
:---------: ![]() |
:-----: ![]() |
:---------: ![]() |
:--------: ![]() |
:--------: ![]() |
:--------: ![]() |
:-------: ![]() |
2 ![]() |
15/12/20 ![]() |
12/3/21 ![]() |
17 ![]() |
31 ![]() |
28 ![]() |
12 ![]() |
0 ![]() |
I have tried using a formula I found elsewhere on this website but it only picks up the relevant months from the column headers in row 1. I need it to pick up the years as well.我尝试使用我在本网站其他地方找到的公式,但它只从第 1 行的列标题中获取相关月份。我也需要它来获取年份。 I wonder if anyone is able to alter this formula to include years as well:
我想知道是否有人能够改变这个公式以包括年份:
=SUMPRODUCT(--(MONTH(ROW(INDIRECT($A2 & ":" & IF($B2="",TODAY(),$B2))))=MONTH(C1))) =SUMPRODUCT(--(MONTH(ROW(INDIRECT($A2 & ":" & IF($B2="",TODAY(),$B2))))=MONTH(C1)))
Note: Row 1 Dates are dates and not text.注意:第 1 行日期是日期而不是文本。
Charles查尔斯
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.