简体   繁体   English

如何获取日期范围之间的天数

[英]How to get Frequency of days between date range

I currently have the following Array formula getting the frequency of days per Fleet Number(this is over all and not linked to any date): 我目前有以下数组公式获取每个机队编号的天数(这是全部,并且未链接到任何日期):

=SUM(IF(FREQUENCY(IF('Management Ops Sheet'!$B$8:$B$500=A6,'Management Ops Sheet'!$A$8:$A$500),'Management Ops Sheet'!$A$8:$A$500)>0,1))

Below is a breakdown of what each part represents : 以下是每个部分代表的细分:

'Management Ops Sheet'!$B$8:$B$500 is the list of Fleet numbers 'Management Ops Sheet'!$B$8:$B$500是机队编号列表

A6 is the fleet number im checking for A6是正在检查的车队编号

'Management Ops Sheet'!$A$8:$A$500 is the list of dates 'Management Ops Sheet'!$A$8:$A$500是日期列表

I have a date range I want to work from: 我有一个要工作的日期范围:

Cell B3 is the Date From Cell B3Cell B3日期

Cell C3 is the Date To Cell C3是日期

What I want to do is get the frequency of the days between(and including) the above dates. 我想要做的是获取上述日期之间(包括该日期)的频率。

Below is the data I am searching through: 以下是我正在搜索的数据:

在此处输入图片说明

| Date      | Fleet No. |   |   |   |
|-----------|:---------:|---|---|---|
| 01-Mar-18 | H05       |   |   |   |
| 01-Mar-18 | H05       |   |   |   |
| 01-Mar-18 | H05       |   |   |   |
| 01-Mar-18 | H05       |   |   |   |
| 01-Mar-18 | H72       |   |   |   |
| 01-Mar-18 | H72       |   |   |   |
| 01-Mar-18 | H77       |   |   |   |
| 01-Mar-18 | H86       |   |   |   |
| 02-Mar-18 | H05       |   |   |   |
| 02-Mar-18 | H72       |   |   |   |
| 03-Mar-18 | H77       |   |   |   |
| 03-Mar-18 | H86       |   |   |   |
| 04-Apr-18 | H86       |   |   |   |

Below is where I am using the formula: 以下是我使用公式的地方:

在此处输入图片说明

| Month:    |          2018-02-01      |     2018-03-01       |                   |   |
|-----------|:------------------------:|----------------------|-------------------|---|
| TOTAL     |  R           56,043.50   | 6745                 | 2.25              |   |
| Fleet No. | Turnover   Month to Date | KM's   Month to Date | Days   Worked M/D |   |
| H05       |  R             3,097.50  | 645                  | 2                 |   |
| H72       |  R           19,864.00   | 2200                 | 2                 |   |
| H77       |  R           20,132.00   | 1400                 | 2                 |   |
| H86       |  R           12,950.00   | 2500                 | 3                 |   |
|           |                          |                      |                   |   |
|           |                          |                      |                   |   |
|           |                          |                      |                   |   |
|           |                          |                      |                   |   |
|           |                          |                      |                   |   |
|           |                          |                      |                   |   |
|           |                          |                      |                   |   |

I dont know how to change the formula to get this to work. 我不知道如何更改公式以使其正常工作。 If any one is able to help I would greatly appreciate it! 如果有人能够提供帮助,我将不胜感激!

Thanks!! 谢谢!!

I finally got it sorted out!! 我终于把它整理好了!! Thanks to @Luuklag and @QHarr that tried helping me out. 感谢@Luuklag和@QHarr试图帮助我。

The formula I landed up using was as follows: 我使用的公式如下:

=IF(A6<>"",SUM(IF(FREQUENCY(IF(MONTH('Management Ops Sheet'!$A$8:$A$500)>=MONTH(B$3),IF(MONTH('Management Ops Sheet'!$A$8:$A$500)<=MONTH(C$3),IF('Management Ops Sheet'!$B$8:$B$500=A6,IF('Management Ops Sheet'!$A$8:$A$500<>"",MATCH('Management Ops Sheet'!$A$8:$A$500,'Management Ops Sheet'!$A$8:$A$500,0))))),ROW('Management Ops Sheet'!$A$7:$A$500)-ROW('Management Ops Sheet'!$A$7)+1),1)),"")

Please note that this is an Array Formula, so you need to push Ctrl + Shift + Enter for this formula to work. 请注意,这是一个数组公式,因此您需要按Ctrl + Shift + Enter才能使此公式起作用。

The following post actually helped me in the right direction: Click Here 以下帖子实际上在正确的方向上对我有所帮助: 单击此处

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

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