What Is the Sleep Duration Calculator?
The Sleep Duration Calculator tells you exactly how long you slept based on the time you went to bed and the time you woke up. It correctly handles sleep that spans midnight — for example, going to bed at 11:00 PM and waking at 7:00 AM — by using modulo-24 arithmetic, so you always get a sensible positive duration.
How to Use It
Enter your bedtime as an hour (0–23) and minute (0–59), then enter your wake time the same way. Use 24-hour notation: 11:00 PM is hour 23, and 7:00 AM is hour 7. The calculator returns your total sleep as hours and minutes, plus a decimal value handy for tracking averages.
The Formula Explained
Bedtime and wake time are each converted to decimal hours (hour + minute ÷ 60). The raw difference (wake − bed) may be negative when sleep crosses midnight, so we wrap it with modulo 24: $$\text{Sleep} = \left(\left(W - B\right) \bmod 24 + 24\right) \bmod 24$$ The double-mod guarantees a result between 0 and 24 hours regardless of the inputs.
Worked Example
Bedtime 23:00 (\(23.0\) hours), wake 07:00 (\(7.0\) hours). Difference = \(7 - 23 = -16\). Apply mod 24:
$$\left(\left(-16\right) \bmod 24 + 24\right) \bmod 24 = 8$$So you slept exactly 8 hours, or 8h 0m.
FAQ
Does it work if I sleep past noon? Yes. As long as wake and bed are within the same 24-hour cycle, any overnight or same-day duration up to 24 hours is computed correctly.
What if bedtime and wake time are identical? The result is 0 hours — the calculator interprets identical times as no measurable sleep rather than a full 24 hours.
How much sleep do I need? Most adults need 7–9 hours per night, though individual needs vary. Use this tool to track your nightly totals over time.