Euro5
asked on
excel count months in date range
I have a column F with dates.
I need to identify the data range in terms of months.
If dates between 11/6/16 and 11/22/16 = 1 (month)
If dates between 11/6/16 and 2/28/17 = 4 (months)
Is this possible? Thanks!
I need to identify the data range in terms of months.
If dates between 11/6/16 and 11/22/16 = 1 (month)
If dates between 11/6/16 and 2/28/17 = 4 (months)
Is this possible? Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want just whole months, use the ROUNDDOWN function to round the result down to a whole number:
=ROUNDDOWN(AboveFormula,0)
=ROUNDDOWN(AboveFormula,0)
Euro5,
You need to check before accepting solution, try below code:
Month-Number.xlsx
You need to check before accepting solution, try below code:
=IF(MONTH(F2)&YEAR(F2)<>MONTH(LOOKUP(2,1/(F:F<>""),F:F))&YEAR(LOOKUP(2,1/(F:F<>""),F:F)),"1 Month",ROUND(YEARFRAC($F$2,MAX(F:F),1)*12,0)& " Months")
Please find attached comparing your accepted solution.Month-Number.xlsx
Shums, maybe you need to read the question; the two ranges of dates were separate examples.
Example 1: Range of dates is 6 Nov to 22 Nov - result is 1 month
Example 2: Range of dates is 6 Nov and 28 Feb - result is 4 months
Your comparison assumes they are only one range.
With your sample, if you delete the 28 Feb from the list my solution shows only 1 month, as does yours.
Example 1: Range of dates is 6 Nov to 22 Nov - result is 1 month
Example 2: Range of dates is 6 Nov and 28 Feb - result is 4 months
Your comparison assumes they are only one range.
With your sample, if you delete the 28 Feb from the list my solution shows only 1 month, as does yours.
Looks like Shum's suggestion is comparing each specific date within the range with the lowest date of the range.
I don't believe that is what was being asked. I believe the range is being looked at as a whole, requiring the number of months between earliest date in the range and the latest date in the range.
I don't believe that is what was being asked. I believe the range is being looked at as a whole, requiring the number of months between earliest date in the range and the latest date in the range.
=DATEDIF(MIN(F:F),MAX(F:F)
Thanks
Rob H
EDITED: added the +1