+ Reply to Thread
Results 1 to 7 of 7

calculate difference between dates then return yes/no if greater/lower than 5

  1. #1
    Registered User
    Join Date
    10-25-2021
    Location
    UK
    MS-Off Ver
    365
    Posts
    30

    calculate difference between dates then return yes/no if greater/lower than 5

    Hello,

    I wonder if someone could help with a formula I'm trying to figure out.

    I want to calculate the number of days between two dates, and if it's 5 or less, I want to return "yes" in a third cell (greater than 5 should return "no").

    For example, difference between A1 and B1 is 4, so C1 returns "yes"

    I hope that makes sense. Is there a formula I can use to do this in one cell? I've had a look and I can't find anything that does what I'm after, but of course that doesn't mean it doesn't exist...

    Many thanks,

    Kerry

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,528

    Re: calculate difference between dates then return yes/no if greater/lower than 5

    Try

    =IF((Date1-Date2) <= 5,"Yes","No")

    in C1 (A1 is latest date)

    =IF((A1-B1) <= 5,"Yes","No")
    Last edited by JohnTopley; 10-25-2021 at 11:13 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,830

    Re: calculate difference between dates then return yes/no if greater/lower than 5

    =IF ( (A1 - B1) <6 , "Yes", "No" )
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Registered User
    Join Date
    10-25-2021
    Location
    UK
    MS-Off Ver
    365
    Posts
    30

    Re: calculate difference between dates then return yes/no if greater/lower than 5

    Thank you both for the super quick replies and the formula - it works (of course).

    A further question if I may...

    I've populated a column with the formula, but where the date cells are blank it obviously still returns yes. Is there a way I can add to the formula to make the cell remain blank unless one or both of the date cells are populated?

    Many thanks,

    Kerry

  5. #5
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,830

    Re: calculate difference between dates then return yes/no if greater/lower than 5

    Which cells A1 , B1 or both


    =IF ( A1 = "", "", IF ( (A1 - B1) <6 , "Yes", "No" ) )

    if any is blank then you want a blank

    =IF( OR ( A1 = "", B1 = "" ) , "", IF ( (A1 - B1) <6 , "Yes", "No" ) )

  6. #6
    Registered User
    Join Date
    10-25-2021
    Location
    UK
    MS-Off Ver
    365
    Posts
    30

    Re: calculate difference between dates then return yes/no if greater/lower than 5

    Amazing, that's perfect , thank you!

  7. #7
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,830

    Re: calculate difference between dates then return yes/no if greater/lower than 5

    you are welcome

+ 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-22-2017, 05:59 AM
  2. How to calculate the difference between two dates
    By gregory4uk in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-20-2014, 03:53 PM
  3. [SOLVED] Return the difference between a value and it's nearest upper and lower neighbour?
    By Prince Dakkar in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-10-2013, 07:21 PM
  4. [SOLVED] if the difference is less than or greater than 50 return value
    By deancorleone in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-02-2013, 07:29 PM
  5. Calculate difference in dates
    By papaexcel in forum Excel General
    Replies: 9
    Last Post: 07-27-2009, 02:43 PM
  6. Calculate difference between dates
    By mprice1988 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-25-2008, 01:32 PM
  7. [SOLVED] How do I calculate the difference between 2 dates (m,d,y) ?
    By ady_sandu in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-29-2005, 01:05 PM

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