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.
Recommended Sleep Duration by Age Group
The ranges below are the commonly cited recommended hours of sleep per 24 hours (naps included for young children). They come from the National Sleep Foundation (NSF) expert panel recommendations and the American Academy of Sleep Medicine (AASM) consensus statements endorsed by the American Academy of Pediatrics (AAP). The two sources differ slightly for a few age bands (for example, NSF gives 9–11 hours for ages 6–13 and AASM gives 9–12 hours for ages 6–12; for infants AASM gives 12–16 hours), so the table uses one consistent set of ranges.
| Age group | Age range | Recommended sleep per 24 h |
|---|---|---|
| Newborns | 0–3 months | 14–17 hours |
| Infants | 4–11 months | 12–15 hours (AASM: 12–16 hours) |
| Toddlers | 1–2 years | 11–14 hours |
| Preschool | 3–5 years | 10–13 hours |
| School-age | 6–12 years | 9–12 hours |
| Teens | 13–18 years | 8–10 hours |
| Adults | 18–64 years | 7–9 hours |
| Older adults | 65+ years | 7–8 hours |
These are general population guidelines, not individual targets. Actual sleep need varies with genetics, health, activity level, and life circumstances, so a person may feel well rested slightly outside these ranges. Guidelines are periodically revised, so check the current NSF and AASM publications for the latest wording.
Interpreting Your Sleep Duration Result
The calculator returns the span between your bedtime and your wake time, which is your time in bed. It is not the same as actual sleep time. Time spent falling asleep (sleep latency), nighttime awakenings, and lying awake before getting up are all included in the result but are not sleep. Someone who is in bed for 8 hours may truly sleep for noticeably less, depending on how long they take to fall asleep and how often they wake.
Crossing midnight is handled with modular arithmetic. Each time is converted to decimal hours (hours + minutes ÷ 60), and the difference is wrapped into a 0–24 hour range. For example, going to bed at 23:30 and waking at 06:45:
$$B = 23 + \frac{30}{60} = 23.5,\qquad W = 6 + \frac{45}{60} = 6.75$$
$$\text{Sleep} = \left(\left(6.75 - 23.5\right) \bmod 24 + 24\right) \bmod 24 = \left(-16.75 + 24\right) = 7.25 \text{ hours}$$
That is 7 hours 15 minutes in bed.
For adults, the AASM and Sleep Research Society consensus recommends 7 or more hours of sleep per night, and the National Sleep Foundation gives a range of 7–9 hours; you can compare your result with them in general terms:
- Below 7 hours: short duration. Regularly sleeping less than 7 hours is associated with health and performance concerns in the consensus statements.
- 7–9 hours: within the recommended range for most adults.
- Above 9 hours: long duration. This can be normal for some people, such as after sleep loss, during illness, or for younger adults, but persistently long sleep is worth noticing.
Because time in bed overstates real sleep, a result near the bottom of a range may mean true sleep is below it. Decimal hours (such as 7.25) make weekly averages easy: add up the nightly decimal values and divide by the number of nights, which shows your typical sleep better than any single night. This tool is informational and is not medical advice; if you have ongoing sleep problems or daytime sleepiness, talk with a qualified healthcare professional.
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.