Find months and days between todays date and another date that is the result of a function?

ScottWilliams324

New Member
Joined
Apr 25, 2014
Messages
2
I have tried to do this for the last hour or so and it's kicking my butt. I'm in Excel 2010, and the cell with the date I want to work from is H22, can anyone help me please?


I'm trying to get the difference of the (date+12 months)-TODAY() to appear in months and days.


Here's the latest thing I tried (that doesn't work):


=IF(DATEDIF(H22,TODAY(),"y")>=1,DATEDIF(H22,TODAY(),"y")&" yrs, "&DATEDIF(H22,TODAY(),"ym")&" mths, "&DATEDIF(H22,TODAY(),"md")&" days",IF(DATEDIF(H22,TODAY(),"ym")>=1,DATEDIF(H22,TODAY(),"ym")&" mths, "&DATEDIF(H22,TODAY(),"md")&" days",DATEDIF(H22,TODAY(),"md")&" days"))


I should also probably note that the date in H22 is the result of another function.


=EDATE(G22,12)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi Scott, and welcome to the board!

Have you tried the DateDif() function? With that you can get the whole number of completed months between two dates. Unfortunately, it doesn't return fractional months, so we'd have to fake something for that.

That function works as
=DateDif( [older date], [more recent date], "m"), and if you combine that with a quick way to count the "missing" days, then ...

=DATEDIF( TODAY(), H22, "m") & " months and " & DAY( TODAY()) - DAY( H22) & IF( DAY( TODAY()) - DAY( H22) = 1, " day", " days")

How does that work for you?

PS: You can also count days ("d") and years ("y"), depending on the granularity of the date difference you want to capture.
 
Upvote 0
Hi Scott, and welcome to the board!

Have you tried the DateDif() function? With that you can get the whole number of completed months between two dates. Unfortunately, it doesn't return fractional months, so we'd have to fake something for that.

That function works as
=DateDif( [older date], [more recent date], "m"), and if you combine that with a quick way to count the "missing" days, then ...

=DATEDIF( TODAY(), H22, "m") & " months and " & DAY( TODAY()) - DAY( H22) & IF( DAY( TODAY()) - DAY( H22) = 1, " day", " days")

How does that work for you?

PS: You can also count days ("d") and years ("y"), depending on the granularity of the date difference you want to capture.

That worked perfectly! Thank you so much! You are awesome!
 
Upvote 0
Oh, gosh. "Perfection" and "awesome" were much higher than I was aiming for; I would have been happy with "workable" and "helpful". You're welcome, and thanks for the feedback.
 
Upvote 0
Wow -- you sure about that?

H​
I​
21​
04/26/2014​
H21: =TODAY()
22​
05/01/2014​
H22: Input
23​
0 months and 25 daysH23: =DATEDIF(H21, H22, "m") & " months and " & DAY(H21) - DAY(H22) & IF( DAY(H21) - DAY( H22) = 1, " day", " days")
 
Upvote 0
Good catch, shg. It was even worse than that. If I put a date that gave us an H22 date a couple of days higher than today, then we could get "1 month and -1 days", which was also short of perfection.

So, maybe this, although it hasn't been checked exhaustively:
=IF( DATEDIF( TODAY(), H22, "m") < 1, "0 months and " & DATEDIF( TODAY(), H22, "d") & IF( DATEDIF( TODAY(), H22, "d") = 1, " day", " days"), DATEDIF( TODAY(), H22, "m") & IF( DATEDIF( TODAY(), H22, "m") = 1, " month", " months") & " and " & ABS( DAY( TODAY()) - DAY( H22)) & IF( ABS( DAY( TODAY()) - DAY( H22)) = 1, " day", " days"))

EDIT: It should also be noted that a date too far in the past, which results in an H22 date in the past (when compared to TODAY()) will result in a #NUM! error, since the DATEDIF() function requires the dates to be put in the correct chronological sequence.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,315
Members
449,218
Latest member
Excel Master

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