简体   繁体   English

Excel-一个月和一天的时间发生在两个日期之间

[英]Excel - Times a month and day occur between 2 dates

I have an Excel sheet where someone types in the date for a yearly bill. 我有一个Excel工作表,其中有人键入年度账单的日期。 I need to know how many times we need to pay that bill between 2 dates. 我需要知道我们需要在2个日期之间支付多少次账单。

For example if a bill is due every year on May 31st, the user will type in 5/31/2014. 例如,如果账单每年5月31日到期,则用户将键入5/31/2014。 I need to know how many time we will pay that bill between 5/15/2014 and 5/15/2018. 我需要知道我们将在2014年5月15日至2018年5月15日之间支付该账单的时间。 (The between dates will change). (日期之间会改变)。 I can't just take the number of years between the start and end dates because in the example above the start and end dates could be 6/1/2014 and 5/30/2018, in which case I only have to pay the bill in 2015, 2016, and 2017, which makes 3 times. 我不能只考虑开始日期和结束日期之间的年数,因为在上面的示例中,开始日期和结束日期可能是6/1/2014和5/30/2018,在这种情况下,我只需要支付账单分别是2015年,2016年和2017年的3倍。

I have this formula which calculates the number of times a certain day occurs between 2 dates: SUMPRODUCT(--(DAY(ROW(INDIRECT($Q$2&":"&$R$2)))=F4)) (Q2 is the begin date, R2 is the end date, and F4 has the day of the month) But I can't figure out how to get this to work for a month and day. 我有一个公式可以计算某天在2个日期之间发生的次数: SUMPRODUCT(--(DAY(ROW(INDIRECT($Q$2&":"&$R$2)))=F4)) (Q2是开始日期,R2是结束日期,F4是一个月中的某天),但我不知道如何使它工作一个月又一天。

假设G4中的特定日期,您可以使用此版本

=SUMPRODUCT(--(TEXT(ROW(INDIRECT($Q$2&":"&$R$2)),"ddmmm")=TEXT(G4,"ddmmm")))

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

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