Prompt
Answer
Excel Formula to Calculate Hours Worked in Shifts
This document outlines the process for calculating hours worked during specific shifts in Excel, specifically for shifts running from 06:00 to 18:00 (Day Shift) and from 18:00 to 06:00 (Night Shift). The provided formula will also account for cases where shifts span across different days.
Requirements
- Input Data: You will need a start time and an end time for each shift.
- Shifts:
- Day Shift: 06:00 to 18:00.
- Night Shift: 18:00 to 06:00.
Formula Breakdown
The formula will be constructed to check:
- If the shift falls into the Day Shift or the Night Shift.
- Calculate the hours worked accordingly.
Formula
Assuming:
- Cell A1 contains Start Time.
- Cell B1 contains End Time.
Use the following formula to calculate hours worked:
=IF(AND(A1
Explanation of the Formula
First Condition:
IF(AND(A1<TIME(6,0,0),B1<TIME(6,0,0)), 0, ...)
- This checks if both the start and end times are before 06:00. If true, hours worked are 0.
Second Condition:
IF(AND(A1<TIME(18,0,0),B1<TIME(18,0,0)), (B1-A1)*24, ...)
- This checks if both times are within the Day Shift (06:00 to 18:00). If true, calculates hours as total time difference multiplied by 24 to convert from days to hours.
Third Condition:
IF(AND(A1>=TIME(6,0,0),A1<TIME(18,0,0)), ...)
- This checks if the start time is within the Day Shift. It calculates hours worked from start time to 18:00 and adds any time worked from 18:00 to the end time if it falls within the Night Shift.
Default Return: If none of the conditions match, the formula defaults to 0 hours.
Practical Example
Input Data
- A1: 17:00 (5 PM)
- B1: 19:00 (7 PM)
Calculation Steps
- The start time (17:00) is within Day Shift.
- The end time (19:00) transitions into Night Shift.
- Formula calculates hours as follows:
- From 17:00 to 18:00 = 1 hour (Day Shift)
- From 18:00 to 19:00 = 1 hour (Night Shift)
- Total hours worked = 1 + 1 = 2 hours.
Conclusion
This formula efficiently calculates the hours worked across day and night shifts while accommodating shifts that cross into different days. For further enhancement of Excel capabilities and advanced techniques, consider exploring the courses available on the Enterprise DNA Platform. This structured approach aids in understanding the application of Excel in practical scenarios.
Description
This document details a formula for calculating hours worked during day and night shifts in Excel, accommodating shifts that cross over midnight and different days. It provides step-by-step breakdown and practical examples.