Number of Months from....

StuartM1

Board Regular
Joined
Oct 6, 2010
Messages
111
Hi folks,

I do NOT have the DATEDIF function on my Excel. I'm not sure why. Anyway, how can I count the number of months as follows?

2016/11 vs. 2017/03 = 4

Any ideas??

Thanks very much!!!!!
 
Ok. So using falcondude's example, I think what im doing wrong is

A1 = "2016/11" typed in. It is Text.
B1 = a date in the custom format of yyyy/mm.

the result is #Value. So how can I calculate a fixed 2016/11 vs a 3/5/2017 converted to yyyy/mm ??

I appreciate all the help really!
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Excel 2010
ABCD
12016/112017034
22016-112017034
32016-112017034
4
2a
Cell Formulas
RangeFormula
D1=DATEDIF(DATE(LEFT(A1,4),RIGHT(A1,2),1),B1,"m")
D2=DATEDIF(A2&"-1",B2,"m")
D3=DATEDIF((A3&"-1")+0,B3,"m")
 
Upvote 0
Ok. So using falcondude's example, I think what im doing wrong is

A1 = "2016/11" typed in. It is Text.
B1 = a date in the custom format of yyyy/mm.

the result is #Value. So how can I calculate a fixed 2016/11 vs a 3/5/2017 converted to yyyy/mm ??

I appreciate all the help really!


=DATEDIF(DATEVALUE(A1&"/1"),B1,"M")

or

=ROUND((EOMONTH(B1,-1)+1)-DATEVALUE(A1&"/1"))/30,0)
 
Upvote 0
Hi Falcon, Dave and snjpverma.

I got it to work until the full date became a calculation. Could you please look at the image below. I get only #VALUE! in Col E. I'm trying to count the number of months from cells in col D to cells in col C.

DateDif_zpsokbzqjy3.jpg
[/URL][/IMG]
 
Upvote 0

Excel 2010
ABCDEFGH
22016/01422783Apple42278number
3Apple2016/01422783Orange42278text
4Orange2016/01422783
52016/011-Oct-153
62016-011-Oct-153
71-Jan-161-Oct-153
8
9T10_1703c2aa
10
2aa
Cell Formulas
RangeFormula
D3=VLOOKUP(A3,F2:G2,2,0)
D4=VLOOKUP(A4,F2:G3,2,0)
E2=DATEDIF(D2,DATEVALUE(C2&"/1"),"m")
E3=DATEDIF(D3,DATEVALUE(C3&"/1"),"m")
E4=DATEDIF(D4+0,DATEVALUE(C4&"/1"),"m")
E5=DATEDIF(D2,DATE(LEFT(C5,4),RIGHT(C5,2),1),"m")
E6=DATEDIF(D5,C6&"-1","m")
E7=DATEDIF(MIN(C7:D7),MAX(C7:D7),"m")
 
Upvote 0
Minor addition and edit


Excel 2010
ABCDEFGH
1Datedif
22016/01422783Apple42278number
32016/01422783
4Apple2016/01422783Orange42278text
5Orange2016/01422783
62016/011-Oct-153
72016-011-Oct-153
81-Jan-161-Oct-153
91-Oct-151-Jan-163
10T10_1703c2aa
11
2aa
Cell Formulas
RangeFormula
D4=VLOOKUP(A4,F2:G2,2,0)
D5=VLOOKUP(A5,F2:G4,2,0)
E2=DATEDIF(D2,DATEVALUE(C2&"/1"),"m")
E3=DATEDIF(D3,(C3&"/1")+0,"m")
E4=DATEDIF(D4,(C4&"/1"),"m")
E5=DATEDIF(D5+0,(C5&"/1"),"m")
E6=DATEDIF(D6,DATE(LEFT(C6,4),RIGHT(C6,2),1),"m")
E7=DATEDIF(D7,C7&"-1","m")
E8=DATEDIF(MIN(C8:D8),MAX(C8:D8),"m")
E9=DATEDIF(C9,D9,"m")
 
Upvote 0
Dave and Falcondude and snjpverma and Amanda,

Can't thank you enough. So it seems the solution is to get the yyyy/mm to become an actual date, and then compare the two with DateDif. I will save this among my 'reference' type files.

Thank you!!!
 
Upvote 0

Forum statistics

Threads
1,216,105
Messages
6,128,859
Members
449,472
Latest member
ebc9

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