+ Reply to Thread
Results 1 to 4 of 4

do not display "0 months"

  1. #1
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    do not display "0 months"

    hi,

    im using the formula below to show the difference between two dates (yrs and months)

    =DATEDIF(D3,F3,"y")&" yrs,"
    &DATEDIF(D3,F3,"ym")&" months"


    my problem is how do i not display "0 months"

    Ex:

    February 01, 2012 and May 31, 2017 difference is 5 yrs, 3 months
    May 23, 1985 and May 31, 2017 difference is 32 yrs, 0 months

    how do i make it to display just "32 yrs" ?

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: do not display "0 months"

    try
    =DATEDIF(A10,C10,"y")&" yrs"&IF(DATEDIF(A10,C10,"ym")=0,"",", "&DATEDIF(A10,C10,"ym")&" months")
    not tested
    Last edited by sandy666; 05-29-2017 at 09:33 PM.

  3. #3
    Valued Forum Contributor
    Join Date
    12-01-2011
    Location
    Philippines
    MS-Off Ver
    Excel 2016
    Posts
    949

    Re: do not display "0 months"

    it work!, thank you!

  4. #4
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: do not display "0 months"

    You are welcome
    I did a little modification with comma after "yrs" (adjust cells to your needs because it was changed to my needs )
    but if it work for you that's good

    read my dancing footnote
    Last edited by sandy666; 05-29-2017 at 09:37 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 08-20-2016, 01:59 AM
  2. Replies: 0
    Last Post: 11-22-2013, 01:36 PM
  3. Replies: 0
    Last Post: 10-21-2013, 05:06 PM
  4. Having trouble with formatting months and days as "MM" and "dd"
    By RyLH87 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-17-2013, 05:52 AM
  5. [SOLVED] Formula needed to display "Pass" or "Fail" if a column contains any values other than "yes
    By andreindy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-26-2013, 05:49 PM
  6. compare two excel sheets using macros and display the result in "true" or "false"
    By gayunana01 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2012, 07:21 AM
  7. [SOLVED] Display , "PASS"," MERIT" or "DISTINCTION"
    By Integrity in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 05-01-2012, 05:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1