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
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Maybe:

=DATEDIF(G6,H6,"y")&" years "&if(DATEDIF(G6,H6,"md")>15,DATEDIF(G6,H6,"ym")+1&" months", DATEDIF(G6,H6,"ym")&" months, "&DATEDIF(G6,H6,"md")&" days"

Datedif first appeared in Excel 2000 so, you should be good to go with versions prior to Excel 2007.
 
Upvote 0
CS

DATEDIF is actually only included for backwards compatibility, it's been around as long as Excel.

Perhaps even longer, I think I remember some link back to Lotus 123.:)

Back to the question - what days are you referring to?
 
Upvote 0
Try

=DATEDIF(G6,H6,"y")&" years "&DATEDIF(G6,H6,"ym")+(DATEDIF(G6,H6,"md")>14)&" months"

However, this can get odd if the roundup makes it go to 12 months..

You'll get 2 years 12 months, instead of 3 years...
 
Upvote 0
for example:

Start date: 12/28/2008
End date: 4/17/2009
result: 3 months 19 days

what I want it to display: 4 months
 
Upvote 0
i'm really only concerned with the months, the maximum month count would never go above 12, so jon, i think that emliminates your concern. Your formula seems to work beautifully, however, is there a way that I can have it only display the month count (with the roundups/downs accounted for)? Is there a way to 'hide' the years portion? It will always just display "0 years", which I know someone, inevitably, will ask me if that needs to be there (@ work).
 
Last edited:
Upvote 0
i guess a =right(A1,9) function works, but is there another way to do it straight away in the datedif formula?
 
Upvote 0
Are you saying you want a total of the months...

like instead of 2 years 5 months, do you want 29 months or 5 months?

If you litterally only want the months, just drop the first part that get's the years

=DATEDIF(G6,H6,"y")&" years "&DATEDIF(G6,H6,"ym")+(DATEDIF(G6,H6,"md")>14)&" months"

Change it to
=DATEDIF(G6,H6,"ym")+(DATEDIF(G6,H6,"md")>14)&" months"
 
Upvote 0
Are you saying you want a total of the months...
like instead of 2 years 5 months, do you want 29 months or 5 months?

jon,
correct. only months, like i said though, it won't go over 12 ever. However, i'm using the formula, and when the count should be exacly 12 months, it displays 0 months. I think because the 'year' portion is taken out of the formula.

Dates being used where problem arises:
start: 12/28/2008 (G6)
end: 12/28/2009 (H6)
formula being used:
=DATEDIF(G6,H6,"ym")+(DATEDIF(G6,H6,"md")>14)&" months"
result: 0 months

formula with 'year' portion intact did the same thing, kinda:
=DATEDIF(G6,H6,"y")&" years "&DATEDIF(G6,H6,"ym")+(DATEDIF(G6,H6,"md")>14)&" months"
result: 1 year 0 months
 
Upvote 0

Forum statistics

Threads
1,216,212
Messages
6,129,547
Members
449,515
Latest member
lukaderanged

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