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

scaggiano70

New Member
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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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)

Replies
3
Views
641
Replies
0
Views
262
Replies
3
Views
523
Replies
2
Views
215
Replies
3
Views
248

1,196,504
Messages
6,015,587
Members
441,903
Latest member
MG12345

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.

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

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