How to Calculate Time Durations Across Midnight

By Prince Yadav, Founder & Lead Developer.

Separate start and end times

A duration is the elapsed time between two moments. If the end clock time is earlier than the start time, the interval may cross midnight rather than be negative.

Convert to a consistent unit

For hours and minutes, convert each time to minutes or use a clear hours-and-minutes method. This helps avoid treating 1 hour 45 minutes as 1.45 hours.

Subtract unpaid breaks when needed

For a shift estimate, calculate the total elapsed time first and then subtract unpaid breaks according to the relevant workplace rule.

Distinguish wall-clock time from elapsed time

When daylight-saving time changes, the clock may skip or repeat an hour. For timestamp-based work, the actual elapsed time can differ from simply subtracting displayed clock values.

Round only according to the rule

Payroll, billing, and attendance systems may use specific rounding increments. Do not assume rounding to the nearest quarter-hour unless the applicable policy says so.

Check the result against the schedule

Verify the date as well as the time for overnight work. Record whether the end time falls on the same day or the following day.

Worked schedule check: include every interval

For a shift that crosses midnight, put the start and end on an actual timeline rather than subtracting clock labels blindly. A shift from 22:40 to 06:10 the next day lasts 7 hours 30 minutes before breaks.

If there is a 20-minute unpaid break, the payable duration is 7 hours 10 minutes, provided the applicable workplace rules treat that break as unpaid. Record whether the end time belongs to the following date; this prevents a negative duration or a one-day error.

For payroll or legal records, follow the employer’s rounding policy and local rules. Do not silently round each segment if the official process rounds only the final total.

Worked example: carry the date across midnight

A shift starts at 22:45 on Monday and ends at 01:15 on Tuesday. From 22:45 to midnight is 1 hour 15 minutes, then midnight to 01:15 adds 1 hour 15 minutes, for a total of 2 hours 30 minutes. If you enter only the clock times, the result can look negative unless the intended next-day finish is clear. For payroll, travel, or event records, capture both date and time and account separately for unpaid breaks or daylight-saving transitions where relevant.

Try the Calculator

Test the worked-example inputs in Time Calculator, then change one input to see how the result responds.

Open Time Calculator