Time Formula

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
788
Office Version
  1. 365
Platform
  1. Windows
Hi,
if i have the following in the format below:

Shift Times:
08:00-17:00
08:00-17:00
08:00-17:00
08:00-17:00
08:00-17:00
08:30-17:30
08:30-17:30
08:30-17:30
08:30-17:30
08:30-17:30
09:00-18:00
09:30-18:30
10:00-19:00

Hour - answers in red which i need formula for (Total hours from available users - example hour 08 - 5 users start at 08:00 = 5 hours plus 5 start at 08:30 = 2.5)
08 - 7.5
09 - 12
10 - 13

Ones who start 08:00 and 08:30 are added to 09:00 as its within their hours

Thanks for any help, i know this looks confusing. I think im best to start converting these into numeric values like 08:00 = 80000 and 08:30 = 80500
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Re: Need help with Time Formula please

@JumboCactuar, first, it seems to me that your 09 figure should be 11.5, not 12 (i.e., 11 people fully on by 9:00 and then add 0.5 for the person who came on at 9:30).

That said, assuming that your Shift Times header is in A1 with the shifts in A2:A14, and assuming your hourly list (08 - 19) begins in C2, the following array "mega-formula" (confirmed with Ctrl+Shift+Enter) in D2 and drag-copied down should work:

Code:
=SUM(IF(VALUE(LEFT(A$2:A$14,2))<C2,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,1,0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=0,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,1,0),0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=30,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,0.5,0),0),0))
 
Upvote 0
Re: Need help with Time Formula please

@JumboCactuar, first, it seems to me that your 09 figure should be 11.5, not 12 (i.e., 11 people fully on by 9:00 and then add 0.5 for the person who came on at 9:30).

That said, assuming that your Shift Times header is in A1 with the shifts in A2:A14, and assuming your hourly list (08 - 19) begins in C2, the following array "mega-formula" (confirmed with Ctrl+Shift+Enter) in D2 and drag-copied down should work:

Code:
=SUM(IF(VALUE(LEFT(A$2:A$14,2))<c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>C2,1,0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=0,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,1,0),0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=30,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,0.5,0),0),0))

thanks for the reply, i tried this but it throws an error:
e12e5540b5.png


after error the first C2 in the formula is highlighted, maybe an error there? =SUM(IF(VALUE(LEFT(A$2:A$14,2))<c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24) style="color: rgb(51, 51, 51); font-size: 12px;">C2,1,0)</c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>

put the shift times in A2 downwards
and hours 06 onwards in C2</c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>
 
Last edited:
Upvote 0
Re: Need help with Time Formula please

@JumboCactuar, yes, somehow a less-than sign got cut from that formula when I pasted it:

Code:
=SUM(IF(VALUE(LEFT(A$2:A$14,2))[B][COLOR=#0000ff]<[/COLOR][/B]<c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>C2,1,0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=0,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,1,0),0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=30,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,0.5,0),0),0))</c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>
 
Last edited:
Upvote 0
Re: Need help with Time Formula please

@JumboCactuar, yes, somehow a less-than sign got cut from that formula when I pasted it:

Code:
=SUM(IF(VALUE(LEFT(A$2:A$14,2))[B][COLOR=#0000ff]<[/COLOR][/B]<c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>C2,1,0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=0,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,1,0),0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=30,IF((TIMEVALUE(MID(A$2:A$14,FIND("-",A$2:A$14)+1,10))*24)>C2,0.5,0),0),0))</c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>

same error but now at this stage:
=SUM(IF(VALUE(LEFT(A$2:A$14,2))<C2,1,0),0))
 
Upvote 0
Re: Need help with Time Formula please

And if your shift times will always look exactly as they do, you can shorten it a bit to this:

Code:
[COLOR=#333333]=SUM(IF(VALUE(LEFT(A$2:A$14,2))[/COLOR][B]<[/B]<c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24) style="color: rgb(51, 51, 51); font-size: 12px;">C2,1,0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=0,IF((TIMEVALUE(MID(A$2:A$14,7,10))*24)>C2,1,0),0),0))+SUM(IF(VALUE(LEFT(A$2:A$14,2))=C2,IF(VALUE(MID(A$2:A$14,4,2))=30,IF((TIMEVALUE(MID(A$2:A$14,7,10))*24)>C2,0.5,0),0),0))</c2,if((timevalue(mid(a$2:a$14,find("-",a$2:a$14)+1,10))*24)>
 
Upvote 0
Re: Need help with Time Formula please

How about this:


Book1
ABCD
1Shift Times:HourAvailable
208:00-17:00087.5
308:00-17:000911.5
408:00-17:001013
508:00-17:00
608:00-17:00
708:30-17:30
808:30-17:30
908:30-17:30
1008:30-17:30
1108:30-17:30
1209:00-18:00
1309:30-18:30
1410:00-19:00
Sheet1
Cell Formulas
RangeFormula
D2=COUNTIF($A$2:$A$114,"<="&TEXT(TIME($C2,0,0),"hh:mm")&"-9")+COUNTIF($A$2:$A$114,TEXT(TIME($C2,30,0),"hh:mm")&"*")/2


WBD
 
Upvote 0
Re: Need help with Time Formula please

@JumboCactuar, as far as I can see, there are no instances where three right parentheses follow that formula portion. Are you remembering to use Ctrl+Shift+Enter after every time you edit?

And my formula is longer than others because you have to account for who goes OFF shift as the hours increase throughout the day.
 
Last edited:
Upvote 0
Re: Need help with Time Formula please

Having said that, it won't produce a value of 1.5 for hour 18 which you might want ...

WBD
 
Upvote 0

Forum statistics

Threads
1,224,833
Messages
6,181,237
Members
453,026
Latest member
cknader

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