Pull data based on condition that a time is between two other different times

scaggiano70

New Member
Joined
May 28, 2015
Messages
1
Hello. My Excel skills are a bit rusty. Could someone help me figure out how I can pull the data I'm looking for (from AA3) based on the condition that O3 must be between 5 am and 10 pm?


N3 = 5/27/15
CE - 5/27/15
O3 = 8:48:00 AM
AA3 = 273

Here's what I have and of course it's not working!


=IF($N3=(CE$1),O3>TIMEVALUE("05:00"), O3<TIMEVALUE("10:00"), AA3," ")

The answer I'm trying to get is 273. This should be true because 8:48 am falls between 5:00 am and 10:00 pm.

Any help would be greatly appreciated!!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You can do this two different ways (probably more) depending on what you eventually want to do with this.

IF(C2=C3,IF(C4>0.3333333,IF(C4<0.91666667,C5,)),)
IF(AND(C2=C3,C4>0.3333333,C4<0.91666667),C5,)

<colgroup><col></colgroup><tbody>
</tbody>

C2 = datefield with 5/27/15
C3 = datefield with 5/27/15
C4 = value to be compared (8:00 AM)
C5 = 273
0.3333333 = serial value for 8 AM (a third of a day)
0.9166667 = serial value for 10 PM

Using nested IF statements you evaluate each item separately and if the test is true it performs the next test. The second method is to use IF(AND where you bundle all your tests up together. If all are true, it grabs the 273 value.

When doing dates and times in Excel when you reference a value, Excel always deals with it as a serial value, so you have to compare against equivalent serial values (.3333300 for 8 AM, .5 for noon, etc)

I hope this is helpful.
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

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