某一天的季度过去的天数

时间:2018-04-17 21:08:07

标签: excel excel-formula

我在无利润的地方工作,我们需要根据美国正常季度(1月,4月,7月,10月)跟踪逗留时间。我们还需要为过去租户的所有数据执行此操作。

我们有:

- 移入日期的一列。

- 移出日期的一栏。

我们想要:

- 告诉我们他们迄今为止住过多少季度的一栏,而不仅仅是搬入日期的四分之一。

- 告诉我们他们在这里居住了多少天的一栏(我们这里有一个简单的日期 - 减去日期公式)。

- 一个专栏告诉我他们这个季度有多少天。

(重要提示:我需要的最重要的公式是可以采取入住日期并告诉我在该季度完成时该人在这里居住了多少天,以及类似的公式可以在搬出日期做同样的事情

非常感谢你们,

1 个答案:

答案 0 :(得分:0)

I could achieve to find a -somehow- generic formula solution for this one. I tried to test all possible scenarios, please let me know if I've missed any.

First we need some helper cells in order to get our formula understand what is the starting day for quarters. 1st row is entered manually for this purpose.

Excel Screenshot

At this point the formula to calculate how many days there are between Move-in & Move-out dates which are within a quarter is as follows. This is for E3, s/b copied to right and down:

=IF(EDATE(E$1,3)-1-E$1-IF($B3>EDATE(E$1,3)-1,0,EDATE(E$1,3)-1-$B3)-IF($A3-E$1<0,0,$A3-E$1)<0,0,EDATE(E$1,3)-1-E$1-IF($B3>EDATE(E$1,3)-1,0,EDATE(E$1,3)-1-$B3)-IF($A3-E$1<0,0,$A3-E$1)+1)

Now the rest is easy. Formula for D3 is as follows (or instead you may sum up the quarters):

=B3-A3+1

And finally, the count of the active quarters in C3 is:

=COUNTIF(E3:I3, ">0")

I wish I had time to explain the formula entirely but I think you may get it if you spend some time on it; there is just some addition/subtraction math behind.

相关问题