Overtime 7pm to 7am

nickspray

New Member
Joined
Feb 7, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'm trying to find a formula that pulls out hours from Start and Ends times of a shift, that fall between 19:00hrs and 07:00hrs (this is our overtime range). The format from our system has both date and hours (in 24hr), which adds to the pain...lol

The example in yellow would return 8.5 hours overtime. The difference would be 2 hours Ordinary time (which I can deal with). We also have overtime all weekends, so recognizing the date to return all hours as OT for this would also be great...

Appreciate anyone providing any assistance at all.

Cheers

1678140385237.png
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
There are probably many examples of overtime formulas in the forum; try searching for ideas.
It is very helpful for people who try to help if you post a concise example with the forum's tool named XL2BB.

The following may help.
Time 2023.xlsm
ABCDEF
1Overtime19:0007:00
2
3
4TotalOvertimeRegular
5Wed 01-Mar-23 18:3002-Mar-23 02:308.007.500.50
6Wed 01-Mar-23 17:0002-Mar-23 03:3010.508.502.00
7Sat 04-Mar-23 15:0005-Mar-23 03:3012.5012.500.00
8
1c
Cell Formulas
RangeFormula
D5:D7D5=(C5-B5)*24
E5:E6E5=(MIN(INT(C5)+$D$1,C5)-MAX(INT(B5)+$C$1,B5))*24
F5:F7F5=D5-E5
E7E7=IF(WEEKDAY(B7,2)>5,(C7-B7)*24,(MIN(INT(C7)+$D$1,C7)-MAX(INT(B7)+$C$1,B7))*24)


You can paste the example to a clean sheet.
 
Upvote 0
Maybe something like this.
TimeTest.xlsm
ABCDEFGHI
1Settings
2Night Shift Start19:00
3Night Shift Stop7:00
4
5Hidden ColumnHidden ColumnHidden Column
6Start TimeEnd TimeNext DayTotal WorkDay Rate HoursNight Rate HoursStop (Adjusted)Night Shift StartNight Shift Stop
76:0019:30013.512.50119:306:007:00
86:3019:00012.512.000.519:006:307:00
918:002:3018.51.007.52:3019:002:30
101:304:30033.0004:301:307:00
1117:003:30110.52.008.53:3019:003:30
Sheet4 (2)
Cell Formulas
RangeFormula
C7:C11C7=IF(B7<$A7,1,0)
D7:D11D7=(G7-A7)*24
E7:E11E7=D7-F7
F7:F11F7=IF(ROUND((I7-H7)*24,2)>D7,0,IF(TRIM(A7)&TRIM(B7)="",0,ROUND(IF((I7-H7)*24<0,0,(I7-H7)*24),2)))
G7:G11G7=IF(C7=1,B7+1,B7)
H7:H11H7=IF(C7=1,IF(A7>$B$2,A7,$B$2),IF(A7>=$B$3,$B$2,A7))
I7:I11I7=IF(C7=1,IF(G7<$B$3+1,G7,$B$3+1),IF(AND(A7>=$B$3,G7 > $B$3),G7,$B$3))
 
Upvote 0
There are probably many examples of overtime formulas in the forum; try searching for ideas.
It is very helpful for people who try to help if you post a concise example with the forum's tool named XL2BB.

The following may help.
Time 2023.xlsm
ABCDEF
1Overtime19:0007:00
2
3
4TotalOvertimeRegular
5Wed 01-Mar-23 18:3002-Mar-23 02:308.007.500.50
6Wed 01-Mar-23 17:0002-Mar-23 03:3010.508.502.00
7Sat 04-Mar-23 15:0005-Mar-23 03:3012.5012.500.00
8
1c
Cell Formulas
RangeFormula
D5:D7D5=(C5-B5)*24
E5:E6E5=(MIN(INT(C5)+$D$1,C5)-MAX(INT(B5)+$C$1,B5))*24
F5:F7F5=D5-E5
E7E7=IF(WEEKDAY(B7,2)>5,(C7-B7)*24,(MIN(INT(C7)+$D$1,C7)-MAX(INT(B7)+$C$1,B7))*24)


You can paste the example to a clean sheet.


That's great, thank you very much. Only issue is that it doesn't seem to work when the start and end dates are the same. When the dates differ, if fires our negatives - see yellow below. Green is perfect

Cheers

1678147580736.png
 

Attachments

  • 1678147341361.png
    1678147341361.png
    44.5 KB · Views: 4
  • 1678147365213.png
    1678147365213.png
    44.6 KB · Views: 4
Upvote 0
Maybe something like this.
TimeTest.xlsm
ABCDEFGHI
1Settings
2Night Shift Start19:00
3Night Shift Stop7:00
4
5Hidden ColumnHidden ColumnHidden Column
6Start TimeEnd TimeNext DayTotal WorkDay Rate HoursNight Rate HoursStop (Adjusted)Night Shift StartNight Shift Stop
76:0019:30013.512.50119:306:007:00
86:3019:00012.512.000.519:006:307:00
918:002:3018.51.007.52:3019:002:30
101:304:30033.0004:301:307:00
1117:003:30110.52.008.53:3019:003:30
Sheet4 (2)
Cell Formulas
RangeFormula
C7:C11C7=IF(B7<$A7,1,0)
D7:D11D7=(G7-A7)*24
E7:E11E7=D7-F7
F7:F11F7=IF(ROUND((I7-H7)*24,2)>D7,0,IF(TRIM(A7)&TRIM(B7)="",0,ROUND(IF((I7-H7)*24<0,0,(I7-H7)*24),2)))
G7:G11G7=IF(C7=1,B7+1,B7)
H7:H11H7=IF(C7=1,IF(A7>$B$2,A7,$B$2),IF(A7>=$B$3,$B$2,A7))
I7:I11I7=IF(C7=1,IF(G7<$B$3+1,G7,$B$3+1),IF(AND(A7>=$B$3,G7 > $B$3),G7,$B$3))
I couldn't quite get it to work...but thank you for your reply
 
Upvote 0
I couldn't quite get it to work...but thank you for your reply
Interesting. I've tested it and it appears to work fine for me. Keep in mind that my example only requires that you enter the start / end times (ex:16:30), not the full date+times (ex: 1/3/2023 16:30). I imagine that might throw things off.

BTW, by posting images of your data you are making less likely that you will get help. Many people otherwise inclined to help see that your data is not easily accessible and move on to someone else's problem because it is not worth the effort to to manually type in a lot of data in order to experiment with your problem. Consider using the free XL2BB tool (link below) to post sample data in a way that makes it accessible to others to copy and paste.

 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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