Day/Night shift calculation

Virtus

New Member
Joined
Sep 30, 2012
Messages
2
Hello all,

In the company I work we use two time frames for different pay rate. The day shift is between 6am and 10pm and the night shift is between 10pm and 6am on the next day. How can write a code to calculate amount of hours worked in each shift? The only input fields should be start and end time.

I would like it to be like this:
ExampleStart timeEnd timeDay shiftNight shiftTotal hours:
01.10.201218:006:004:008:0012:00

<tbody>
</tbody>

I am calculating the total amount of hours worked like this:
=IF(OR(C6="";D6="");"";MOD(D6-C6;1))


Thanks!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hello all,

In the company I work we use two time frames for different pay rate. The day shift is between 6am and 10pm and the night shift is between 10pm and 6am on the next day. How can write a code to calculate amount of hours worked in each shift? The only input fields should be start and end time.

I would like it to be like this:
Example
Start time
End time
Day shift
Night shift
Total hours:
01.10.2012
18:00
6:00
4:00
8:00
12:00

<TBODY>
</TBODY>

I am calculating the total amount of hours worked like this:
=IF(OR(C6="";D6="");"";MOD(D6-C6;1))


Thanks!
Try this...

Book1
ABCDEF
1DateInOutTotalDayNight
210/1/20126:00 PM6:00 AM12:004:008:00
Sheet1

This formula entered in D2:

=MOD(C2-B2,1)

This formula entered in E2:

=(B2>C2)*MEDIAN(0,C2-1/4,16/24)+MAX(0,MIN(22/24,C2+(B2>C2))-MAX(1/4,B2))

This formula entered in F2:

=D2-E2

Format D2:F2 as h:mm
 
Upvote 0
Todd,

Great formula. I need something like this very similar for my pilot logbook spreadsheet. The only difference is that my total time is already calculated for me and I'm able to import into the spreadsheet along with the start and end times for my flights. Here's the catch, my total time takes into account any time change that took place from takeoff and landing. So, therefore, the total time might only show 1 hr flight time when you look at the takeoff and landing time and it's 2 hours difference due a time change from say Central time zone to Eastern time zone. Therefore I don't use the formula for total time like you have in the example above (D2).

So, how would you need to change up the formula in order to compensate for time zone changes? Because there are many times when I cross time zones so the Dep and Arr times are reflective of local times and not total duration of the flight.

Have I confused you yet? Lol. Let me know if you might have a solution. I can email you the spreadsheet so you can possibly help me out. I truly appreciate it!!!

Tony
 
Upvote 0

Forum statistics

Threads
1,216,046
Messages
6,128,489
Members
449,455
Latest member
jesski

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