time schedule

william marinho

New Member
Joined
Aug 4, 2023
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Good morning, I must make a time schedule that tells me how many hours in the night shift i have worked, night shift is between 22:00 and 05:00 in the morning of the next day.
I am using this formula =IF(H17>=V$15;MOD(W$15-H17;1);IF(H17<=W$15;MOD(W$15-H17;1);(IF(K17>=V$15;MOD(K17-V$15;1);IF(K17<=V$15;MOD(K17-V$15;1);0))))) but if I work in a time different of 22:00 to 05:00 lets say 13:00 to 19:00 the cell shows me 21:00 when it should show 00:00. How can I fix it?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Please provide a minisheet of the cells you are referencing. Include labels or a description of the contents of each cell referenced in your formula.
 
Upvote 0
Here is an example, first column is the the predicted time schedule, no problems with that, then the real time worked. You can see, if I work out of the range between 22:00 and 05:00 the I will have 21:00 marked in the cell where 00:00 must be shown. If I finish my work at 22:00 then it start the counting correctly. I left it highlighted. I hope you guys can help me. What I am trying to do is, if I work my shift out of the range 22:00 to 05:00 of the next day I have 00:00 as response, and if I work within this range it must show me the of hours that I worked on this range i.e. if I start to work at 21:00 and finish at 06:00 of the next day this column must show me 07:00, if I start ate 00:00 and work until 06:00 it must show me 05:00.
Thank you
planilha.png
 
Upvote 0
Will this provide the results you need?

Book1
ABCDEFG
1start timeend timenight shift hoursNight Shift Start22:00Night Shift End5:00
213:0022:000:00
322:004:006:00
413:0019:000:00
522:0023:001:00
622:0023:591:59
722:001:003:00
822:002:004:00
922:003:005:00
1022:004:006:00
11
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=IF(AND(B2>A2,B2<=NSCom),0,IF(B2>=A2,B2-A2,TIMEVALUE("23:59:59")-(A2-0.00001)+(B2-TIMEVALUE("00:00:00"))))
Named Ranges
NameRefers ToCells
NSCom=Sheet2!$E$1C2:C10
 
Upvote 0
Will this provide the results you need?

Book1
ABCDEFG
1start timeend timenight shift hoursNight Shift Start22:00Night Shift End5:00
213:0022:000:00
322:004:006:00
413:0019:000:00
522:0023:001:00
622:0023:591:59
722:001:003:00
822:002:004:00
922:003:005:00
1022:004:006:00
11
Sheet2
Cell Formulas
RangeFormula
C2:C10C2=IF(AND(B2>A2,B2<=NSCom),0,IF(B2>=A2,B2-A2,TIMEVALUE("23:59:59")-(A2-0.00001)+(B2-TIMEVALUE("00:00:00"))))
Named Ranges
NameRefers ToCells
NSCom=Sheet2!$E$1C2:C10
 
Upvote 0
I had to do an adjustment but now is working on the opposite way

=SE(E(K18>H18;);0;SE(K18>=H18;K18-H18;VALOR.TEMPO("23:59:59")-(H18-VALOR.TEMPO("00:00:01")+(K18-VALOR.TEMPO("00:00:00")))))
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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