The midnight census counts the inpatients in a bed at the end of a day. A stay is in the census of a date when it was admitted on or before that date and discharged after it, or has no discharge date yet:
SELECT COUNT(*) AS census
FROM hd_encounters
WHERE encounter_type = 'inpatient'
AND admit_date <= DATE '2026-03-15'
AND (discharge_date > DATE '2026-03-15' OR discharge_date IS NULL);
So a patient admitted that day counts, a patient discharged that day does not, and a same-day stay never appears. Patient days for a month add up the census of every night in it.
Average length of stay (ALOS) averages discharge date minus admit date over ended inpatient stays, with a same-day stay at 0 days.
The pitfalls: counting patients discharged that day (>=), losing the stays with no discharge date, and letting observation stays in. Observation is outpatient status, even when the patient sleeps in a bed.
The midnight census of 15 March 2026.