Solved

# Extract # of Years from Date formula

Posted on 2011-02-21
Medium Priority
227 Views
Last Modified: 2012-05-11
Experts,
I have this formula:
=YearsMonthsDays(\$A\$8,\$C\$8,\$D\$4,\$D\$5)

and it returns X Years, Y Months and Z Days

I need to incorporate the # of Years into a formula I am using
How can I extract the Years from the YearsMonthsDays formula?

Lets say that the YearsMonthsDays = 10 years and 5 months and 10 days...I would want the answer to be 10 only and no fraction of years.

I hope this makes sense...please ask if need additional information.
0
Question by:pdvsa
• 2
4 Comments

LVL 50

Expert Comment

ID: 34947278
It isn't an inbuilt formula, it is a User Design Function (UDF)

Can you please post the code that sits behind this UDF

Cheers

Dave
0

LVL 50

Accepted Solution

barry houdini earned 2000 total points
ID: 34947315
Like your other question you could extract that from the result, so if you have this text in B2

10 years and 5 months and 10 days

you can get the years with

=LEFT(B2,FIND(" ",B2)-1)+0

regards, barry
0

Author Closing Comment

ID: 34947342
thanks Barry...   Yes, it was not a UDF, which was a good question to ask and I failed to mention that.  I really forgot that is was not a UDF.
0

LVL 50

Expert Comment

ID: 34947403
Assuming it was a UDF you would be better off tweaking the UDF function internally for a direct answer rather than manipulating the output

For example you can use an Optional variable to dictate years only

Cheers

Dave
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
###### Suggested Courses
Course of the Month3 days, 13 hours left to enroll

#### 599 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.