简体   繁体   English

Excel:计算日期范围内的月数,但仅限于特定年份

[英]Excel: Calculate number of months in date range, but only for specific year

My sheet looks like this (sample data)我的工作表看起来像这样(示例数据)

"Rate" "Begin" "End" “速率”“开始”“结束”
"1$" "01.01.2011" "01.01.2015" "1$" "01.01.2011" "01.01.2015"
"2$" "01.06.2012" "01.08.2013" "2$" "01.06.2012" "01.08.2013"

I want to calculate the number of months for the date ranges which fall in specific years (2012, 2013, 2014) to estimate volume (= months*rate) For example in the 2nd line I would get 6 months for 2012 (=12$) and 7 months for 2013 (=14$).我想计算属于特定年份(2012、2013、2014)的日期范围的月数以估计数量(= 月*率)例如在第二行中,我将获得 2012 年的 6 个月(=12$ ) 和 2013 年的 7 个月 (=14$)。 How can I achieve this?我怎样才能做到这一点?

Assuming you have your data in A1:C3 then list the years in the header row, eg D1 = 2012, E1 = 2013, F1 = 2014 then in D2 use this formula:假设您在 A1:C3 中有数据,然后在标题行中列出年份,例如 D1 = 2012、E1 = 2013、F1 = 2014 然后在 D2 中使用以下公式:

=IFERROR(DATEDIF(MAX($B2,DATE(D$1,1,1)),MIN($C2,DATE(D$1+1,1,1)),"m"),0)*$A2

format as currency and copy across and down格式为货币并上下复制

Assumes you are using Excel 2007 or later and that columns B and C contain valid dates.假设您使用的是 Excel 2007 或更高版本,并且 B 列和 C 列包含有效日期。 In earlier Excel versions you can use this alternative formula在早期的 Excel 版本中,您可以使用此替代公式

=LOOKUP(99^99,IF({1,0},0,DATEDIF(MAX($B2,DATE(D$1,1,1)),MIN($C2,DATE(D$1+1,1,1)),"m")*$A2))

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

相关问题 在Excel中,如何计算日期范围之间的天数,仅计算一周中的特定天数 - In Excel, how to calculate # of days between a date range, counting only specific days of week 在 Excel 中查找今天和特定日期之间的月数 - Find the number of months between today and a specific date in Excel Excel 将月份识别为特定年份一部分的公式 - Excel formula for recognizing months as a part of a specific year 如何在Excel中计算2个日期范围之间的星期数 - How to calculate the number of weeks between 2 date range in excel Excel公式可计算年和月的日期差 - Excel formula to calculate date difference in years and months Excel COUNTIFS计算日期范围内的月数 - Excel COUNTIFS count months in date range Excel:获取给定年份的开始日期和结束日期之间的月份,或者如果开始日期在上一年中则获得截止日期为止的月份 - Excel: get months between start and end date in given year or months through end date if start is in a prior year 计算范围内的特定天数 - Calculate number of specific days in range 计算excel中年份和周数的月份 - calculate the month from the year and week number in excel 根据我们在 Excel 中定义的会计年度从日期计算周数。 星期以星期日至星期六计算 - Calculate week number from the date based on the Fiscal year defined by us in Excel . Week is counted as Sunday to Saturday
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM