Forum Discussion

nobody4's avatar
nobody4
Copper Contributor
Jul 13, 2023

excel formula

i want to compare between two days and after calulation i would like to show in arange like <1 , 1-2 , 3-4 etc

 

How can i set the fomula in excel 

 

example  date of join 1 Jan 2023 compare with 30 Jun 2023. 

 

1 Reply

  • LeonPavesic's avatar
    LeonPavesic
    Silver Contributor

    Hi nobody4,

    If I understood your question right, you want to compare the number of days between two dates and display the result in a specific range format, then you can use the following formula:

    =IF(B1-A1 < 1, "<1", IF(AND(B1-A1 >= 1, B1-A1 <= 2), "1-2", IF(AND(B1-A1 >= 3, B1-A1 <= 4), "3-4", "5+")))

    In this formula, we can assume that the "date of join" is in cell A1 and the "comparison date" is in cell B1. 

     

    Here's how the formula should work:


    - If the difference between the comparison date (B1) and the "Date of Join" (A1) is less than 1 day, it will display "<1"
    - If the difference is between 1 and 2 days (inclusive), it will display "1-2"
    - If the difference is between 3 and 4 days (inclusive), it will display "3-4"
    - For any difference greater than 4 days, it will display "5+"

    Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

    Kindest regards

    Leon Pavesic

Resources