using datedif & if function to highlight the Ageing defference

I need to combine the datedif & If function in way in which if years = 0, then calculate months & Days, if year & month = 0 then calculate days if all is false then calculate years, months & days
Yashashri NarkarAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you show examples? It is not usual practice to show datedif result in such manner
ShumsExcel & VBA ExpertCommented:
Assuming your Start Date is in A1 & End Date is in B1, try below:

=IF(DATEDIF(A1,B1,"y")=0,DATEDIF(A1,B1,"m")+1&" Months "&DATEDIF(A1,B1,"d")+1& " Days",IF(AND(DATEDIF(A1,B1,"y"),DATEDIF(A1,B1,"m"))=0,DATEDIF(A1,B1,"d")&" Days",DATEDIF(A1,B1,"y")&" Years "&DATEDIF(A1,B1,"m")+1&" Months "&DATEDIF(A1,B1,"d")+1&" Days"))

Kindly note when you are calculating Years, Months & Days, you also need to consider if Year, Month or Day are greater than 1. Then your formula will be too long.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ShumsExcel & VBA ExpertCommented:
No comment has been added to this question in more than 14 days, so it is now classified as abandoned.

If you feel this question should be closed differently, post an objection and a moderator will read all objections and then close it as they feel fit. If no one objects, this question will be closed automatically the way described above.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.