checking if two times are between certain hours

Kmitchell

Active Member
Joined
Feb 27, 2007
Messages
361
Office Version
  1. 365
Platform
  1. Windows
This should be easier than I'm making it...

Start times all sit in column J (military time), and stop times sit in column K (also military time). The duration in minutes sits in column M.

I want to put in a formula that says if columns J and K are between the hours of 7:30am and 3:30pm, then grab the duration minutes sitting in column M, otherwise leave blank.

I get an error message when I enter in the below formula. Any suggestions?

=IF(AND(J2>=7:30,K2<=15:30),M2,"")
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You need too use a slightly different syntax for the times to be recognised, try

=IF(AND(J2>="7:30"+0,K2<="15:30"+0),M2,"")
 
Upvote 0
Thanks - that wasn't quite accounting for all cases.

The below formula works. Now I'm just trying to get it work for instances where hours are after 3:30pm and before 7:30am.

IF(AND($J$3>TIMEVALUE("07:00"),$K$3<TIMEVALUE("15:30")),$M$3,"")
 
Upvote 0
Your formula got cut off......

Not sure what you need to modify, if you still need some assistance can you give some examples?
 
Upvote 0
Sorry about that. I think I'm good now.

I used the below formula for all instances b/w 7am and 3:30pm.

IF(AND(J11>TIMEVALUE("07:00"),K11<TIMEVALUE("15:30")),M11,0)

My work around formula was just to take all those instances that had 0 minutes.

IF(N11=0,M11,IF(N11>1,""))
 
Upvote 0

Forum statistics

Threads
1,216,060
Messages
6,128,549
Members
449,458
Latest member
gillmit

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