counting time

orsm6

Active Member
Joined
Oct 3, 2012
Messages
496
Office Version
  1. 365
Platform
  1. Windows
I have a start time (BG13) and a finish time (BH13) which could contain any start and finish time (even start time today, finish time is tomorrow)..... is it possible to count how many 30 minute blocks are between (and including) those times?

as example 5:30am start, 7:38 start (it is 2 hours I know) but there are 5 x 30 minute values.....

5:30 = 1
6:00 = 2
6:30 = 3
7:00 = 4
7:30 = 5

hope this makes sense.
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
"Between those times" (5:30 = 0) and "5 x 30 minute values" is a contradiction, but you seem to be asking for:


Excel 2010
ABC
15:30 AM7:38 AM5
Sheet13
Cell Formulas
RangeFormula
C1=1+ROUND((B1-A1)*24*2,0)


roundup works too
 
Last edited:
Upvote 0
OK, this solution hasn't done exactly what I need to.

in the examples above, I am trying to count the number of half hour intervals. this is the formula I am using: =FLOOR((BH13-BG13)*24,0.5)*2
rounding does not always work in every case, here is an example

start time: 8:55am - finish time 2:30pm...... If you count how many 30 minute intervals there are (including 2:30) you get 12.... start at 9am, then 9:30, then 10 etc etc
the formula I am using above returns 11 because it doesn't include the 2:30

the example at the top of this thread using a formula returns 4, but it isn't counting the 5:30am time and I need it to return 5.

hope this makes sense and is even possible to do.

cheers
 
Upvote 0
The formula I wrote above returns 12, do you not want it to?


Excel 2010
ABC
18:55 AM2:30 PM12
Sheet1
Cell Formulas
RangeFormula
C1=1+ROUND((B1-A1)*24*2,0)
 
Last edited:
Upvote 0
it does work, but it also doesn't work haha.

here are some more examples.
- 3:00am to 6:45am = 7 instances your formula returns 9 (so I then removed the 1= part of formula, it returns 8)
- 4:15am to 11:00 pm = 14 instances, ROUND((BH42-BG42)*24*2,0) works for this time.
- 4:45am to 7:30am = 5 instances but the formula returns value of 6
 
Upvote 0
here are some more examples.
- 3:00am to 6:45am = 7 instances your formula returns 9 (so I then removed the 1= part of formula, it returns 8)
- 4:15am to 11:00 pm = 14 instances, ROUND((BH42-BG42)*24*2,0) works for this time.
- 4:45am to 7:30am = 5 instances but the formula returns value of 6

Hi, shouldn't the expected result for the first example be 8? And the last example be 6?

If not, why not?


Excel 2013/2016
ABC
105:3007:385
203:0006:458
304:1511:0014
404:4507:306
505:3005:301
605:3006:002
705:3006:303
805:3007:004
905:3007:305
1008:5514:3012
Sheet1
Cell Formulas
RangeFormula
C1=1+((FLOOR(B1,"00:30")-CEILING(A1,"00:30"))/"00:30")
 
Upvote 0
This matched everything in FormR's sample too, not sure how it will look on your actual data:


Excel 2010
ABC
15:307:385
23:006:458
34:1511:0014
44:457:306
55:305:301
65:306:002
75:306:303
85:307:004
95:307:305
108:5514:3012
Sheet2
Cell Formulas
RangeFormula
C1=INT((B1-A1)*24*2)+1
 
Upvote 0
Hi!

If I understand correctly what you want, so the formula below (that is not the most smart, but I think do the job) can help you.

In B54 and copy the range B54:C54 to the right:

=SUMPRODUCT(--(RIGHT(ROW(INDIRECT(ROUND(IF(B1,B1*24,0.5),2)*100&":"&
ROUND(((B52 < B1)+B52)*24,2)*100)),2)={"00","50"}))+(B1=0)


ABCDEFGHIJKLMNOPQRSTUV
1Start Time 05:30 08:55 03:00 16:45 04:45 00:00 04:31 23:00 23:00 23:31
2CountCountCountCountCountCountCountCountCountCount
3 05:30 01 09:00 01 03:00 01 17:00 01 05:00 01 00:00 01 05:00 01 23:00 01 23:00 01
4 06:00 02 09:30 02 03:30 02 17:30 02 05:30 02 00:30 02 05:30 02 23:30 02 23:30 02
5 06:30 03 10:00 03 04:00 03 18:00 03 06:00 03 01:00 03 06:00 03 00:00 03 00:00 03
6 07:00 04 10:30 04 04:30 04 18:30 04 06:30 04 01:30 04 06:30 04 00:30 04 00:30 04
7 07:30 05 11:00 05 05:00 05 19:00 05 07:00 05 02:00 05 07:00 05 01:00 05 01:00 05
8 11:30 06 05:30 06 19:30 06 07:30 06 02:30 06 07:30 06 01:30 06
9 12:00 07 06:00 07 20:00 07 03:00 07 08:00 07 02:00 07
10 12:30 08 06:30 08 20:30 08 03:30 08 08:30 08 02:30 08
11 13:00 09 21:00 09 04:00 09 09:00 09
12 13:30 10 21:30 10 04:30 10 09:30 10
13 14:00 11 22:00 11 05:00 11 10:00 11
14 14:30 12 22:30 12 05:30 12
15 23:00 13 06:00 13
16 06:30 14
49 23:00 47
50 23:30 48
51
52End Time 07:38 14:30 06:45 23:00 07:30 23:59 10:29 02:31 01:01 23:59
53
54Result 05 12 08 13 06 48 11 08 05 00
55
******************************************************************************************************************

<tbody>
</tbody>


Markmzz
 
Last edited:
Upvote 0
count how many 30 minute blocks are between (and including) those times?

shouldn't the expected result for the first example be 8? And the last example be 6?

That's what I was wondering too

=SUMPRODUCT(--(RIGHT(ROW(INDIRECT(ROUND(IF(B1,B1*24,0.5),2)*100&":"&
ROUND(((B52 < B1)+B52)*24,2)*100)),2)={"00","50"}))+(B1=0)

This might be the best one if the last line should return zero:


Excel 2010
ABCDE
15:307:38555
23:006:45888
34:1511:00141414
44:457:30666
55:305:30111
65:306:00222
75:306:30333
85:307:00444
95:307:30555
108:5514:30121212
110:0023:59484848
1223:3123:59-1.8E-1510
Sheet2 (2)
Cell Formulas
RangeFormula
C1=1+((FLOOR(B1,"00:30")-CEILING(A1,"00:30"))/"00:30")
D1=INT((B1-A1)*48)+1
E1=SUMPRODUCT(--(RIGHT(ROW(INDIRECT(ROUND(IF(A1,A1*24,0.5),2)*100&":"&ROUND(((B1 < A1)+B1)*24,2)*100)),2)={"00","50"}))+(A1=0)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,638
Messages
6,120,674
Members
448,977
Latest member
moonlight6

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