businessman, schedule, agenda, business, time, appointment, management, planning, deadline, brown business, brown time, brown company, brown businessman, brown plan, brown schedule, brown planning, brown management, agenda, agenda, agenda, agenda, agenda, appointment, appointment, deadline. Before you act on SLA deadline calculators formula
Photo by TheDigitalArtist on Pixabay

Industry

Part of How SLA deadline calculators determine due dates

Before you act on SLA deadline calculators formula

The SLA deadline calculators formula: walk the schedule to find a due moment, keep a segment ledger for pauses, and handle the two boundaries that break both.

Finding a due moment is not the reverse of measuring elapsed business hours, even though the two look symmetrical. Measuring clips a known span. Finding a due moment walks forward until a budget runs out, and the walk has boundaries the measurement never meets.

Nothing is computed for you here. What follows is the walk, the ledger that survives a pause, and the figures to test an implementation against.

What to take away

  • Compute a due moment by walking open intervals and consuming the budget, not by adding hours to a timestamp and adjusting afterward.
  • A pause is a segment in a ledger, not a number added to the deadline. Adding time to a deadline gives a different answer from re-walking with less budget.
  • Two boundaries decide whether an implementation is righta start outside the window, and a budget that runs out exactly at a closing time.

The walk


<figure class="inline-figure">
  <img src="/inline/sla-deadline-calculators-formula-fig1-1280.webp" alt="Flowchart of the SLA deadline walk loop with clamp and closing checks (Before you act on SLA deadline calculators formula)" loading="lazy" decoding="async" />
  <figcaption>The loop that walks the schedule forward, with the two boundary checks that decide each step. <a href="https://workdaydatecalculator.com/image-licence">Image: Workday Date Calculator</a></figcaption>
</figure>
remaining = budget
cursor    = start
loop:
  if the cursor's day is closed or a rest day:
      cursor = next day's opening; continue
  clamp the cursor up to the day's opening
  if the cursor is at or past the day's closing:
      cursor = next day's opening; continue
  available = closing - cursor
  if remaining <= available:  return cursor + remaining
  remaining = remaining - available
  cursor = next day's opening

Two lines do the work. Clamping the cursor up to opening makes a start before hours act like a start at opening. Treating a cursor at or past closing as the next day stops a zero-length day from being consumed.

Reversing that comparison, so a cursor exactly at closing stays on the day, gives an answer correct on every test except those ending exactly at closing.

Worked figures

An 09:00 to 17:00 window, Monday to Friday, nothing closed unless stated. March 2027.

Start, budget, due

Start

Fri 5th 15:00
4 hours
Fri 5th 15:00
8 hours
Fri 5th 15:00
24 hours
Fri 5th 17:30
4 hours
Sat 6th 10:00
4 hours
Fri 5th 15:00
4 hours, Mon closed
Thu 4th 09:00
40 hours

Budget

Fri 5th 15:00
Mon 8th 11:00
Fri 5th 15:00
Mon 8th 15:00
Fri 5th 15:00
Wed 10th 15:00
Fri 5th 17:30
Mon 8th 13:00
Sat 6th 10:00
Mon 8th 13:00
Fri 5th 15:00
Tue 9th 11:00
Thu 4th 09:00
Wed 10th 17:00

Due

Fri 5th 15:00
Fri 5th 15:00
Fri 5th 15:00
Fri 5th 17:30
Sat 6th 10:00
Fri 5th 15:00
Thu 4th 09:00
StartBudgetDue
Friday 5th 15:004 hoursMonday 8th 11:00
Friday 5th 15:008 hoursMonday 8th 15:00
Friday 5th 15:0024 hoursWednesday 10th 15:00
Friday 5th 17:304 hoursMonday 8th 13:00
Saturday 6th 10:004 hoursMonday 8th 13:00
Friday 5th 15:004 hours, Monday closedTuesday 9th 11:00
Thursday 4th 09:0040 hoursWednesday 10th 17:00

Rows four and five are the same answer from two different starts, because both starts clamp forward to Monday's opening. An implementation that returns Monday 11:00 for either has treated the start as though it were inside the window.

The last row is the boundary. Forty hours is exactly five open days, and the answer lands precisely at a closing time rather than rolling to the next morning. Both readings are defensible in principle; what is not defensible is having no test that pins the choice.

The pause ledger

A ticket that stops and restarts is a sequence of segments, each with a state and two moments.

Segment ledger

  1. Fri 15
    00 running starts, 2 business hours
  2. Fri 17
    00 paused, 0.5 business hours
  3. Mon 09
    30 running resumes
  4. Mon 11
    00 running ends, 1.5 business hours
StateSegmentBusiness hours in itCounts
runningFriday 15:00 to Friday 17:002yes
pausedFriday 17:00 to Monday 09:300.5no
runningMonday 09:30 to Monday 11:001.5yes

Consumed is the sum of the running segments, here 3.5 hours. The remaining budget is the original minus that, and the due moment is found by walking forward from the end of the last segment with the remaining budget.

The alternative, pushing the deadline out by the length of each pause, gives a different answer whenever a pause straddles a closing time. The pause above is 64 clock hours and half a business hour, so adding clock time to a deadline moves it by more than a working week.

Add the business hours in the pause and it is closer but still not equal, because the deadline lands wherever the walk lands and the walk depends on where the cursor was. Re-walking is the only arrangement that stays consistent.

The three-state model this ledger implements is set out under service level deadlines, and the elapsed-hours arithmetic each segment uses is under working hours.

Two properties worth testing

Re-running the calculation with the same ledger must give the same answer. That is idempotence in the plain sense, and an implementation that stores a computed due moment and then adjusts it in place will fail it after the second pause.

Two properties to test

  • Re-run same ledgersame answer
  • Stored due moment adjusted in place fails
  • Walk and measure must agree
  • Four hours due Monday 11:00 measures four
  • Disagreement is a start-end clipping error

Measuring and stepping must agree. If the walk says a budget of four hours is due at Monday 11:00, then measuring the business hours between the start and Monday 11:00 must return four. Any disagreement is a clipping error at one of the two ends, and it will be at the start.

What the formula does not decide

It does not decide the schedule, the closure list, or whether a period counts in hours or open days. Where a rule of procedure governs counting, that rule wins.

In the United States, the federal civil rules set their own method in Rule 6 on computing and extending time. A contract can adopt a similar method by reference.

Where the counting is in whole days rather than hours, the walk is the same shape with a coarser step, and it is under adding business days. The closure list itself, with its publisher and version, is under how closure calendars are made.

Common questions

Should a due moment at exactly closing time roll to the next morning?

Either, provided the choice is documented and tested. The failure is silence, because the two implementations agree on everything except this case and will diverge in production.

What should a budget of zero return?

The next moment the schedule is open, or the start itself if it is already inside the window. Returning the start unchanged when the start is a Saturday is the answer that causes trouble downstream.

Can the ledger be reconstructed from a stored due moment?

No, and that is the argument for storing the segments. A due moment is a derived value, and a derived value that has been adjusted in place has lost its derivation.

Does a clock change affect the walk?

Only where the window spans the transition. A daytime window is unaffected, because the transitions happen in the small hours, but the test is worth writing before someone widens the window.

More in Industry

Latest from Review Desk