简体   繁体   English

显示日期范围

[英]Indicating range of dates

I want to get all active records by quarter from 2016 to 2019 (given start and end dates) The approach I'm trying to use is adding columns for each quarter, 1 will indicate active, 0 will indicate inactive.我想从 2016 年到 2019 年按季度获取所有活动记录(给定开始和结束日期)我尝试使用的方法是为每个季度添加列,1 表示活动,0 表示不活动。

In the attached sample image, you can see the results I am trying to get.在随附的示例图像中,您可以看到我试图获得的结果。 Record 1 was active only in Q1-2016, so it will have 0 for the other quarters.记录 1 仅在 2016 年第一季度有效,因此其他季度为 0。 Record 5 active starting Q4-2016 until Q4-2017.从 2016 年第 4 季度到 2017 年第 4 季度,记录 5 项活动。 Record 8 active all periods.记录 8 个活跃的所有时期。 (00/00/0000 represents currently active) (00/00/0000 代表当前活动)

在此处输入图像描述

The formula I was using only shows they are active during the end_date quarter.我使用的公式仅显示它们在 end_date 季度期间处于活动状态。 For example for record 5, H9 is shown as active, but G9 should also be 1. They formula I am currently using shows it as 0. All the 1's marked in blue are captured by the formula.例如,对于记录 5,H9 显示为活动,但 G9 也应为 1。我目前使用的公式将其显示为 0。所有标记为蓝色的 1 都被公式捕获。 This formula does not work for active records (8 to 10)此公式不适用于活动记录(8 到 10)

How could I approach this?我怎么能接近这个? If you have a different approach to what I am trying to achieve (getting active records by quarter), please let me know.如果您对我想要实现的目标有不同的方法(按季度获取活动记录),请告诉我。

Put the start dates of the quarters in the row above and use those as reference(you can make the text white to hide the values).将季度的开始日期放在上面的行中并将其用作参考(您可以将文本设为白色以隐藏值)。 Then use this formula in E5, copy over and down.然后在E5中使用这个公式,上下复制。

=--(SUMPRODUCT((ROW(INDEX($ZZ:$ZZ,E$3):INDEX($ZZ:$ZZ,IF(F$3="",EDATE(E$3,3),F$3)))>=$C5)*(ROW(INDEX($ZZ:$ZZ,E$3):INDEX($ZZ:$ZZ,IF(F$3="",EDATE(E$3,3),F$3)))<=$D5))>0)

It iterates the days in the quarter and checks if any days are in the date range.它迭代季度中的日子并检查日期范围内是否有任何日子。

在此处输入图像描述

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

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