Greater than the result of a DateDif

weerder

New Member
Joined
May 22, 2020
Messages
9
Office Version
  1. 2019
Platform
  1. Windows
I am using DateDif to come up with a result such as 1 year 4 months or 5 years 11 months. I want to have an adjacent column, possibly using IF but not necessarily, that will give me a result of One, if more than one year, Five, if more than five years etc. Can this be done? TIA
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
"if more than one year, Five, if more than five years etc. "
What if the result is exactly 1 year or exactly 5 years?
It is probably easier to calculate from the original information.

Dates Time.xlsm
ABCDEFGH
2StartEnd
31-Jan-225-May-231 Years and 4 Months11.00011
41-Jan-225-May-231.33972602715.00015
51-Jan-225-May-275
4f
Cell Formulas
RangeFormula
C3C3=DATEDIF(A3,B3,"y")&" Years and "&DATEDIF(A3,B3,"ym")& " Months"
C4C4=YEARFRAC(A4,B4,1)
D3D3=LOOKUP((B3-A3)/365,G3:H4)
D4D4=LOOKUP(C4,G3:H4)
D5D5=LOOKUP(YEARFRAC(A5,B5,1),G4:H5)
 
Upvote 0
"if more than one year, Five, if more than five years etc. "
What if the result is exactly 1 year or exactly 5 years?
It is probably easier to calculate from the original information.

Dates Time.xlsm
ABCDEFGH
2StartEnd
31-Jan-225-May-231 Years and 4 Months11.00011
41-Jan-225-May-231.33972602715.00015
51-Jan-225-May-275
4f
Cell Formulas
RangeFormula
C3C3=DATEDIF(A3,B3,"y")&" Years and "&DATEDIF(A3,B3,"ym")& " Months"
C4C4=YEARFRAC(A4,B4,1)
D3D3=LOOKUP((B3-A3)/365,G3:H4)
D4D4=LOOKUP(C4,G3:H4)
D5D5=LOOKUP(YEARFRAC(A5,B5,1),G4:H5)
Thanks for this Dave. It is not critical whether it is exactly 1 or 5 years so I have not bothered. What I am after is a text value in the adjacent cell if the value is greater than.
 
Upvote 0
Did you try the suggested alternatives?
What result do you expect?
Please post a few examples and the result that you expect.
What "Text Value" do you expect for 5.0 Years?
What "Text Value" do you expect for 5 Years 6 months?
What "Text Value" do you expect for 7.5 years?

Dates Time.xlsm
ABCDEFG
1
2StartEnd
31-Jan-225-May-23ABC1ABC
41-Jan-225-May-27XYZ5XYZ
501-01-225-Jan-25ABC
6
4f
Cell Formulas
RangeFormula
D3D3=VLOOKUP((B3-A3)/365,$F$3:$G$4,2,1)
D4D4=VLOOKUP((B4-A4)/365,F3:G4,2,1)
D5D5=VLOOKUP((B5-A5)/365,$F$3:$G$3,2,1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,217,359
Messages
6,136,097
Members
449,991
Latest member
IslandofBDA

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