DATEDIF function

C.S.

Board Regular
Joined
Nov 20, 2008
Messages
89
I need a datedif formula to look at the months and days between two dates and display only the months. However, i need the result (number of months) to be rounded up if the days are 15 or more and rounded down if 14 or less. right now i'm using this formula, but i'm not sure how or where to alter:
=DATEDIF(G6,H6,"y")&" years "&DATEDIF(G6,H6,"ym")&" months "&DATEDIF(G6,H6,"md")&" days"

also, is the datedif function a useable function in older versions of excel? (2003, xp, etc.) I'm using 2007.

thanks,
cs
 
thanks barry, you did it again! how simple! I don't get it though, how does just the "+15" part effect it like it does? i.e. rounding up or down.

clint
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
It may not give the exact rounding you want (it depends on the month lengths) but DATEDIF effectively rounds the months down so if you add half a month to the latter date (or subtract half a month from the start date) then you'll virtually get what you want, i.e. rounding to the nearest month

It's just a little bit imprecise because, of course, 15 days is not always half a month, depending on the month in question.......
 
Upvote 0
the 14th and 15th are static regardless of the month so its no concern. awesome, thanks for the explanation.

thank you very much barry!

c.s.
 
Upvote 0

Forum statistics

Threads
1,223,445
Messages
6,172,177
Members
452,446
Latest member
walkman99

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