dcsimg
Results 1 to 2 of 2

Thread: [RESOLVED] Need help with a formula

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,025

    Resolved [RESOLVED] Need help with a formula

    This formula

    =IF(B8<> " ",DATEDIF(B7,B8,"y") &" years, "&DATEDIF(B7,B8,"ym") &" months, " &DATEDIF(B7,B8,"md") &" days","")

    produces

    0 years, 9 months, 6 days


    How can I change it so that when the years calculation produces zero that the "0 years, " is omitted, but kept if the year is not zero?

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    40,118

    Re: Need help with a formula

    I think you just need to add another If like this:
    Code:
    =IF(B8<> " ", If(DATEDIF(B7,B8,"y")=0,"", DATEDIF(B7,B8,"y") &" years, ")&DATEDIF(B7,B8,"ym") &" months, " &DATEDIF(B7,B8,"md") &" days","")

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width