Condition to return number of hours

sebastianchu

New member
Joined
Apr 22, 2015
Messages
4
Reaction score
0
Points
0
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
 
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
 
Hi Hiten Patel, thanks for your wonderful guide. It works perfectly well. Thanks!!!!!!
 
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
 
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,

Please find the following solution.

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
 
wow, thank you for all these wonderful help. really appreciate it.
 
Back
Top