Formula to determine if time is within range

odonovanc

Board Regular
Joined
Oct 4, 2017
Messages
60
Office Version
  1. 365
Let's say I have a cell that has the following value in cell A1: 8/31/2023 11:54:00 PM. The cell is in mm/dd/yyyy hh:mm format.

I want to write a formula that will tell me if the time in that cell is between 23:00 (11:00 PM) and 7:00 (7:00 AM). I need the date to be ignored altogether.

Help!!
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
How about
Excel Formula:
=IF(MEDIAN(INT(A1)+TIME(11,0,0),INT(A1)+31/24,A1)=A1,"y","n")
 
Upvote 0
How about
Excel Formula:
=IF(MEDIAN(INT(A1)+TIME(11,0,0),INT(A1)+31/24,A1)=A1,"y","n")
Not working. For example, for this time 8/31/2023 10:05:00 PM it gave me a y it should have been a n. also 8/25/2023 4:01:00 AM gave me a n but should be a y
 
Upvote 0
Not for me it doesn't
Fluff.xlsm
AB
131/08/2023 10:05n
231/08/2023 11:54y
Sheet6
Cell Formulas
RangeFormula
B1:B2B1=IF(MEDIAN(INT(A1)+TIME(11,0,0),INT(A1)+31/24,A1)=A1,"y","n")
 
Upvote 0
Oops won't work for the morning, try
Excel Formula:
=IF(OR(MOD(A1,1)>=11/24,MOD(A1,1)<=7/24),"y","n")
 
Upvote 0
Not for me it doesn't
Fluff.xlsm
AB
131/08/2023 10:05n
231/08/2023 11:54y
Sheet6
Cell Formulas
RangeFormula
B1:B2B1=IF(MEDIAN(INT(A1)+TIME(11,0,0),INT(A1)+31/24,A1)=A1,"y","n")
I am copying and pasting your formula. Is it because your format is different? My format is mm/dd/yyyy hh:mm yours is dd/mm/yyyy hh:mm

08/31/2023 23:54​
y
08/31/2023 22:05​
y
08/25/2023 04:01​
n
08/31/2023 20:45​
y
 
Upvote 0
See post#5
Still giving me a "Y" for 8/31/2023 10:05:00 PM

There is actually a lot of Y that does not belong

08/31/2023 23:54​
y
08/31/2023 22:05​
y
08/25/2023 04:01​
y
08/31/2023 20:45​
y
08/31/2023 21:06​
y
08/31/2023 19:41​
y
08/31/2023 19:51​
y
08/31/2023 20:30​
y
08/31/2023 19:49​
y
08/31/2023 19:35​
y
08/31/2023 17:49​
y
08/31/2023 06:13​
y
 
Upvote 0
All of those times are between 11pm & 7am, so should return y
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,963
Members
449,094
Latest member
Anshu121

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