Greater than equal to Less than with Days and Hours equalling a certain number

exc

New Member
Joined
Apr 16, 2021
Messages
5
Office Version
  1. 2019
Hello, I'm trying to create a formula to automatically calculate a number based on the amount of time (Days and Hours).

Here's the values I need to input.

If C2 is greater than or equal to 4 Hours but less than 8 hours =1, if C2 is greater than or equal to 8 hours but less than 12 hours =2, if C2 is greater than or equal to 12 hours but less than 1 days and 4 hours =3. If C2 is greater than or equal to 1 days 4 hours but less than 1 days 8 hours =4, if C2 is greater than or equal to 1 days 8 hours but less than 1 days 12 hours =5.

Hopefully this isn't too complex to write, thanks in advance!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi,

What exactly is in C2, a Date/Time value, or just numbers?
Can you post a sample?
 
Upvote 0
Sure, one cell says 18 hours, 52 minutes. Another one says 1 days, 8 hours, 30 minutes. The minutes don't really matter to me just days and hours.
 
Upvote 0
Is it Real Date/Time values (a valid number) custom formatted to read as x days x hours, x minutes, or Text?
What does =ISNUMBER(C2) return?
 
Upvote 0
=ISNUMBER(C2) returns false. Here is the formula I used to create the C2 value. =IF(INT(B2-A2)>0,INT(B2-A2)&" days, ","")&IF(HOUR(B2-A2)>0,HOUR(B2-A2)&" hours, ","")&IF(MINUTE(B2-A2)>0,MINUTE(B2-A2)&" minutes ","")
 
Upvote 0
Ok, I'm going to use B2 & A2 for the formula, otherwise, we'll have to Parse out the Text value of C2.

Try this:

Excel Formula:
=LOOKUP(INT(B2-A2)*24+HOUR(B2-A2),{4,8,12,28,32},{1,2,3,4,5})
 
Upvote 0
Solution
You're welcome, thanks for the feedback.

Additional comments I'd like to make.
Rather than using your current formula in C2 as you posted in Post #5, which produces a Text String, you can do this, which retains a Real Date/Time value:

Book3.xlsx
ABC
24/14/2021 18:004/16/2021 17:001 days, 23 hours, 0 minutes
3^ Custom Format like below
4d "days, "h" hours, "m" minutes"
Sheet924
Cell Formulas
RangeFormula
C2C2=B2-A2


Edited just now.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,423
Members
448,961
Latest member
nzskater

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
Back
Top