Calculating y,m,d not including blanks

Taiter

New Member
Joined
Jun 27, 2012
Messages
8
Greetings,

I am trying to calculate the amount of time from a date (m/d/yyyy) to show # years, # month, # day but ignore cell if blank. The formula I am using is IF([@[BEGIN DATE-MIN ]]<>"",DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"y"), DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"y")&" year, ")&IF(DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"ym"), DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"ym")&" month, ","")&IF(DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"md"), DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"md")&" day","")

It works fine when IF([@[BEGIN DATE-MIN ]]<>"", is not used but it drops the year with it. What am I missing?

Appreciate any help.
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,480
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
It looks like you should be using:

=IF([@[BEGIN DATE-MIN ]]<>"",IF(DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"y"), DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"y")&" year,"")&IF(DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"ym"), DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"ym")&" month, ","")&IF(DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"md"), DATEDIF([@[BEGIN DATE-MIN ]],TODAY(),"md")&" day",""),"")
 

Taiter

New Member
Joined
Jun 27, 2012
Messages
8
Thank you for the reply. Now it causes an error and highlights the "ym".
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,480
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Which "ym" (there are two) and what is the error message?
 

Watch MrExcel Video

Forum statistics

Threads
1,127,787
Messages
5,626,876
Members
416,208
Latest member
tan21

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
Top