Convert Age to Number format not working

BradleyS

Active Member
Joined
Oct 28, 2006
Messages
351
Office Version
  1. 2010
Platform
  1. Windows
I have a formula to get the age in years and months which works great =DATEDIF($B2,$C2,"y")&"."&DATEDIF($B2,$C2,"ym"), but I need to convert it into a number, so that I can use it in an autofilter.
However, when I try to convert it to a number format, I just can't get it in the correct format.
The 3.10 shows as 3.1 and so does the actual 3.1 value, so one cannot be distinguished by the other. I ideally need the numbers to show as listed under the 1st column.
I have tried TextToColumns, PasteSpecial Multiply by 1, VBA .Value = .Value

If you add an autofilter to the table and use the last column which has been converted to a number and try to filter ages <=3.4, you will see that it includes 3.10 and 3.11, which I do not want.
Does anyone have a resolve to my predicament?

RequiredDate of BirthTodayCalc AgeConverted
3.1205/11/202005/11/20244.04
3.1105/12/202005/11/20243.113.11
3.105/01/202105/11/20243.103.1
3.0905/02/202105/11/20243.93.9
3.0805/03/202105/11/20243.83.8
3.0705/04/202105/11/20243.73.7
3.0605/05/202105/11/20243.63.6
3.0505/06/202105/11/20243.53.5
3.0405/07/202105/11/20243.43.4
3.0305/08/202105/11/20243.33.3
3.0205/09/202105/11/20243.23.2
3.0105/10/202105/11/20243.13.1
305/11/202105/11/20243.03
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Why not go straight to numeric with =DATEDIF(B5,C5,"m")/12

(Although there are some known calculation issues with DATEDIF, so it may not produce equivalent results in all cases)
 
Upvote 0
We can't recommend what you are trying to do since it will look like a decimal value but actually be y.mm but I think this will get you what you want.
(Stephen is showing the actual value in years as a real decimal value.)
Note:
• You have 3 as showing 3 but 4 showing as 3.12. That's not going to work so I have it showing as 4.
• I have formatted the column as Number with 2 Decimal places.

Book1
ABCDEF
1Result y.mmDate of BirthTodayCalc AgeConvertedOP Required
24.005/11/20205/11/2024443.12
33.115/12/20205/11/20243.113.113.11
43.105/01/20215/11/20243.13.13.1
53.095/02/20215/11/20243.93.93.09
63.085/03/20215/11/20243.83.83.08
73.075/04/20215/11/20243.73.73.07
83.065/05/20215/11/20243.63.63.06
93.055/06/20215/11/20243.53.53.05
103.045/07/20215/11/20243.43.43.04
113.035/08/20215/11/20243.33.33.03
123.025/09/20215/11/20243.23.23.02
133.015/10/20215/11/20243.13.13.01
143.005/11/20215/11/2024333
Sheet1
Cell Formulas
RangeFormula
A2:A14A2=VALUE(DATEDIF($B2,$C2,"y")&"."&TEXT(DATEDIF($B2,$C2,"ym"),"00"))
 
Upvote 0
Thank you, but neither really worked correctly. In the end I just removed the decimal that separated the y and m and it worked fine, as a whole number for the autofilter.
 
Upvote 0
Thank you, but neither really worked correctly. In the end I just removed the decimal that separated the y and m and it worked fine, as a whole number for the autofilter.
Another way:

=DATEDIF($B2,$C2,"y")*100+DATEDIF($B2,$C2,"ym")
 
Upvote 0
Solution
Another way:

=DATEDIF($B2,$C2,"y")*100+DATEDIF($B2,$C2,"ym")
This worked great! as i had a few other age ranges to deal with, which didn't work with my method, but this has done the trick.
Thank you
 
Upvote 0

Forum statistics

Threads
1,223,532
Messages
6,172,878
Members
452,486
Latest member
standw01

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