# Thread: Condition to return number of hours

1. ## Condition to return number of hours

Eg, I got a starting time at 9am and an ending time at 11am and would like to condition that if the number of hours is less than 4 hrs, it will give me 4hr and if more than 4 hours, it should give me 8 hrs. Can anyone help? greatly appreciate any help as I tried all means and unable to solve this. A thousand thanks

2. Hello Sebastian,

This is my first reply, I have recently joined this group so please ignore my presentation and you may find better solutions later from other members.

Please input 9:00 AM in cell A1 and 11:00 AM in cell B1

Insert the following formula in cell C1

=IF(((B1-A1)*24)<=4,4,8)

(FORMAT FOR C1 SHOULD BE GENERAL OR NUMBER IT WILL GIVE YOU NUMBER OF HOURS INSTEAD OF TIME)

Hiten Patel

3. Hi Hiten Patel, thanks for your wonderful guide. It works perfectly well. Thanks!!!!!!

4. Hi Hiten, can I post another questions? assuming an event starts at 9AM and ends at 6PM and I would like to have a return in terms of 4 hrs block, so it should give me 3 blocks as an answer. How do i go about getting this? Really appreciate your great guidance. Thanks

5. Originally Posted by sebastianchu
Hi Hiten, can I post another questions? assuming an event starts at 9AM and ends at 6PM and I would like to have a return in terms of 4 hrs block, so it should give me 3 blocks as an answer. How do i go about getting this? Really appreciate your great guidance. Thanks
You are welcome Sebastian,

Enter 9:00 in cell A1 and 18:00 in cell B1

copy paste following formula in cell C1

=ROUNDUP(((B1-A1)*24)/4,0)

Cell C1 should be in Number or General format

Regards,
Hiten

6. wow, thank you for all these wonderful help. really appreciate it.

7. Thanks!

#### Posting Permissions

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