Count periods between to dates/times (lookup)

Woofy_McWoof_Woof

Board Regular
Joined
Oct 7, 2016
Messages
60
Office Version
  1. 365
Platform
  1. Windows
Hi, I posted an earlier version of this and though partly resolved, it was suggested I post a separate question to hopefully finish it off.

In the attached, I'd like to count as either one or zero if a lookup shows an event in that particular half hour. The formula in the attached (col G and H) returns the first and last half hour ok but I'd also like the half hours in-between to be flagged as one as well. Columns L and M shows this manually but i'd like a formula that i can drag down for the whole year as I have hundreds of affected half hours in my master spreadsheet and do not really want to count them individually. Thanks for any help that can be provided.

lookup_test.xlsx
ABCDEFGHIJKLMN
1StartEndStart lookupEnd lookupDateCount of startCount of endSum of countDateCount of startCount of endSum of count
201 May 2022 05:42:2001 May 2022 07:18:2001/05/2022 05:3001/05/2022 07:0001-May-2022 05:0000001-May-2022 05:00000
301 May 2022 09:02:4901 May 2022 12:39:4901/05/2022 09:0001/05/2022 12:3001-May-2022 05:3010101-May-2022 05:30101
401 May 2022 14:48:0201 May 2022 17:56:0201/05/2022 14:3001/05/2022 17:3001-May-2022 06:0000001-May-2022 06:00011
501 May 2022 19:48:0201 May 2022 19:56:0201/05/2022 19:3001/05/2022 19:3001-May-2022 06:3000001-May-2022 06:30011
601-May-2022 07:0001101-May-2022 07:00011
701-May-2022 07:3000001-May-2022 07:30000
801-May-2022 08:0000001-May-2022 08:00000
901-May-2022 08:3000001-May-2022 08:30000
1001-May-2022 09:0010101-May-2022 09:00101
1101-May-2022 09:3000001-May-2022 09:30011
1201-May-2022 10:0000001-May-2022 10:00011
1301-May-2022 10:3000001-May-2022 10:30011
1401-May-2022 11:0000001-May-2022 11:00011
1501-May-2022 11:3000001-May-2022 11:30011
1601-May-2022 12:0000001-May-2022 12:00011
1701-May-2022 12:3001101-May-2022 12:30011
1801-May-2022 13:0000001-May-2022 13:00000
1901-May-2022 13:3000001-May-2022 13:30000
2001-May-2022 14:0000001-May-2022 14:00000
2101-May-2022 14:3010101-May-2022 14:30112
2201-May-2022 15:0000001-May-2022 15:00011
2301-May-2022 15:3000001-May-2022 15:30011
2401-May-2022 16:0000001-May-2022 16:00011
2501-May-2022 16:3000001-May-2022 16:30011
2601-May-2022 17:0000001-May-2022 17:00011
2701-May-2022 17:3001101-May-2022 17:30011
2801-May-2022 18:0000001-May-2022 18:00000
2901-May-2022 18:3000001-May-2022 18:30000
3001-May-2022 19:0000001-May-2022 19:00000
3101-May-2022 19:3011201-May-2022 19:30112
3201-May-2022 20:0000001-May-2022 20:00000
3301-May-2022 20:3000001-May-2022 20:30000
3401-May-2022 21:0000001-May-2022 21:00000
3501-May-2022 21:3000001-May-2022 21:30000
3601-May-2022 22:0000001-May-2022 22:00000
3701-May-2022 22:3000001-May-2022 22:30000
3801-May-2022 23:0000001-May-2022 23:00000
3901-May-2022 23:3000001-May-2022 23:30000
Sheet1
Cell Formulas
RangeFormula
C2:D5C2=VLOOKUP(A2,$F$2:$F$39,1,TRUE)
G2:G39G2=COUNTIF($C$2:$C$2987,F2)
H2:H39H2=COUNTIF($D$2:$D$2987,F2)
I2:I39,N2:N39I2=SUM(G2:H2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
N2:N39Cell Value>0textNO
L2:M39Cell Value>0textNO
I2:I39Cell Value>0textNO
G2:H39Cell Value>0textNO
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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