DATEDIF Month Count with Rounding Up?

slam

Well-known Member
Joined
Sep 16, 2002
Messages
869
Office Version
  1. 365
  2. 2019
Hi all,

I have a simple formula to count the months between two dates:

=DATEDIF(H2,J2,"M")

I'm struggling to tweak it to count any months, regardless of how many days within that month. ROUNDUP is perhaps not what I need.

So if my first date was 28 Feb 2023, and my second date was 01 Mar 2023, I would want the count to be 2 Months. With the formula above, it's giving me a 0 of course.

Any help would be greatly appreciated.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How about
Excel Formula:
=month(J2)-month(H2)+1
 
Upvote 1
Solution
Perfect, thank you so much for your speedy reply!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
How about
Excel Formula:
=month(J2)-month(H2)+1
Hi Fluff,

I apologize for not noticing this earlier, but I just noticed that this formula won't work if the dates span multiple years. For instance, if I have a Start Date of 01 Jun 2022, and an End Date of 31 Dec 2024, which I think is 31 months, it will only display 7. It's ignoring the year, and only counting the months June to December.

Could you please help me accommodate this?

Thank you so much
 
Upvote 0
How about
Excel Formula:
=MONTH(J2)-MONTH(H2)+1+(YEAR(J2)-YEAR(H2))*12
 
Upvote 0
T202303a.xlsm
HIJK
1Number of months
228-02-2301-03-232
301-06-2231-12-2432
4
4e
Cell Formulas
RangeFormula
K2:K3K2=DATEDIF(H2-DAY(H2),J2,"m")+1
 
Upvote 0
Ignore previous post. The expected answer was 31.

=DATEDIF(H2-DAY(H2),J2-DAY(J2)+1,"m")+1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,545
Messages
6,120,132
Members
448,947
Latest member
test111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top