Solved

Extract # of Years from Date formula

Posted on 2011-02-21
4
218 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
Comment
Question by:pdvsa
  • 2
4 Comments
 
LVL 50

Expert Comment

by:Dave Brett
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

by:
barry houdini earned 500 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

by:pdvsa
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

by:Dave Brett
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

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

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

Join & Ask a Question