Solved

Extract # of Years from Date formula

Posted on 2011-02-21
4
214 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now