Displaying age (but not displaying zero values )

locolindo

New Member
Joined
Dec 5, 2014
Messages
12
Hi there,
I want to display the age of animals based on the date they were born relative to the current date. That part I think I can figure out.
However, I want to display it in a way that if the number for the year or the month is zero, it would not appear in the cell
For example, a dog that is 3 months and 5 days would display "3 months, 5 days, but NOT: 0 Years, 3 months, 5 days. When the dog got to be 1 year and 5 days, it would display: 1 year, 5 days, but not 1 year, 0 months, 5 days... Understood? In other words: any years, months or year that would be "0" would not be displayed, but the rest would...
Thanks,
Locolindo
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hello,

Can you give your current way to create those age?
That way, it will be easy to modify it correctly.
 
Last edited:
Upvote 0
Hi there,
I want to display the age of animals based on the date they were born relative to the current date. That part I think I can figure out.
However, I want to display it in a way that if the number for the year or the month is zero, it would not appear in the cell
For example, a dog that is 3 months and 5 days would display "3 months, 5 days, but NOT: 0 Years, 3 months, 5 days. When the dog got to be 1 year and 5 days, it would display: 1 year, 5 days, but not 1 year, 0 months, 5 days... Understood? In other words: any years, months or year that would be "0" would not be displayed, but the rest would...
Thanks,
Locolindo

Assuming C5 is where the birth date is stored, change as needed.

Code:
=IF(DATEDIF(C5,TODAY(),"y")=0,"",DATEDIF(C5,TODAY(),"y") &" years,")&IF(DATEDIF(C5,TODAY(),"ym")=0,"",DATEDIF(C5,TODAY(),"ym") &" months,") &IF(DATEDIF(C5,TODAY(),"md")=0,"",DATEDIF(C5,TODAY(),"md") &" days")
 
Upvote 0
Thanks!!!! This is exactly what I wanted

Assuming C5 is where the birth date is stored, change as needed.

Code:
=IF(DATEDIF(C5,TODAY(),"y")=0,"",DATEDIF(C5,TODAY(),"y") &" years,")&IF(DATEDIF(C5,TODAY(),"ym")=0,"",DATEDIF(C5,TODAY(),"ym") &" months,") &IF(DATEDIF(C5,TODAY(),"md")=0,"",DATEDIF(C5,TODAY(),"md") &" days")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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