# health.gestational-age
Status: needs review and sign-off by a qualified clinician before it is published. Not a medical device; for decision support only; always follow local clinical guidelines.
Gestational age on a date, as completed weeks plus days (12+3), and the
estimated due date (EDD), from the first day of the last menstrual period
(LMP). This is the LMP estimate only: NICE recommends dating a pregnancy by
ultrasound between 11+2 and 14+1 weeks, and once a dating scan has been done
its dates supersede these.
**The rule.** Naegele's rule puts the due date 280 days (40+0 weeks) after the
LMP, which assumes a 28-day cycle with ovulation on day 14. A longer or
shorter cycle moves ovulation, so both the due date and the gestational age
are shifted by the difference from 28 days:
dueDate = LMP + 280 + (cycleLengthDays - 28)
totalDays = (onDate - LMP) - (cycleLengthDays - 28)
weeks = totalDays div 7, days = totalDays mod 7
With a 35-day cycle the due date is a week later and the pregnancy is a week
less advanced on any date. Pass 28 for the unadjusted rule. This is exactly
what the NHS due date calculator does, and its published answers are among
the vectors (LMP 15 March 2026: due 20 December 2026 on a 28-day cycle, 27
December on 35 days, 12 December on 20 days, 5 January 2027 on 44 days).
**Limits, and why they are errors.**
- `cycleLengthDays` must be a whole number from 20 to 44, the range the NHS
calculator accepts.
- A measuring date before the adjusted start of pregnancy (the LMP plus the
cycle shift) is an error, not a negative age: with a 35-day cycle, three
days after the LMP is not yet 0+0.
- A gestational age above 44+0 weeks (308 days) is an error asking for the
dates to be checked. Pregnancy normally lasts 37 to 42 weeks from the LMP;
44 weeks is a guard rail against a wrong year or a transposed date, not a
clinical threshold, and a clinician should confirm it.
Dates are ISO `YYYY-MM-DD`; the measuring date is always an argument, never
today's date. Leap days are counted like any other day.
## Sources
- NHS, "Due date calculator" (nhs.uk): takes the first day of the last period
and a cycle length that "must be between 20 and 44 days"; pregnancy
"normally lasts from 37 weeks to 42 weeks from the first day of your last
period". Its outputs for the dates above were checked on 23 September 2026.
https://www.nhs.uk/pregnancy/finding-out/due-date-calculator/
- NICE guideline NG201, "Antenatal care" (2021), recommendation 1.2.14: offer
an ultrasound scan between 11+2 and 14+1 weeks to determine gestational age.
https://www.nice.org.uk/guidance/ng201/chapter/Recommendations