Formula For Date Conversion

meppwc

Well-known Member
Joined
May 16, 2003
Messages
604
Office Version
  1. 365
Platform
  1. Windows
I have a column that tells me the age of items. Those entries appear as below
3 Years and 2 Months
Is there a formula that will convert this to a number form with 2 decimal points?
The above example would be something like 3.50
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Dates Time.xlsm
AB
23 Years and 2 Months3.166667
4e
Cell Formulas
RangeFormula
B2B2=TEXTBEFORE(A2," ")+TEXTBEFORE(TEXTAFTER(A2," ",3)," ")/12
 
Upvote 0
Assuming your first value is in cell A2 and that your text only contains letters, spaces and numbers (and no other type of character), then put this formula in cell B2, format the cell to display only two decimal places and then copy this formula down to the bottom of your data...
Excel Formula:
=LET(n,TEXTSPLIT(UPPER(A2),VSTACK(" ",CHAR(SEQUENCE(26,,65))),,1),INDEX(n,1)+INDEX(n,2)/12)

NOTE 1: This formula will handle any text as long as no other numbers are part of it and that there are always a number for the years and a number for the months (years first, months second) even if that number is 0. So, the text could look like this "3 Years and 2 Months" or like this "He was 5 years and 0 months old" and it would work.

NOTE 2: If your text could contain other characters (mainly, punctuation), let me know and I'll modify the formula to handle them.
This works perfectly. I am very grateful to you.
 
Upvote 0

Forum statistics

Threads
1,215,365
Messages
6,124,511
Members
449,166
Latest member
hokjock

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