How to Calculate a One-Day Length of Stay in Excel
Question details
The user needs an Excel formula to calculate the length of stay between an admission and discharge date, ensuring that same-day events return a minimum of '1' instead of '0'.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Calculating hospital, clinic, or hotel stay durations using admission and discharge dates.
- Observed behavior
- Standard subtraction of same-day dates returns 0, but the calculation requires a minimum of 1 day to accurately reflect the billing or tracking logic.
Ensure that your admission and discharge date columns are properly formatted as 'Date' or 'Date and Time' in Excel, rather than plain text, to prevent calculation errors.
Use the MAX Function to Ensure a Minimum of One Day
The MAX function is the most efficient and reliable way to ensure your calculation never returns a value less than 1.
By comparing the standard date difference (Discharge Date - Admission Date) against the number 1, the MAX function will automatically output the higher number. This elegantly solves the issue of same-day zero returns.
Click on the cell where you want the calculated length of stay to appear (for example, cell C2).
Type the formula =MAX(1, B2-A2), assuming cell B2 contains the discharge date and cell A2 contains the admission date.
Press the Enter key. If both dates are the same, the formula will return 1. If the difference is greater, it will return the actual number of days.

Use the IF and INT Functions to Compare Dates
Use this method if your cells contain both dates and times (timestamps) and you only want to compare the calendar days while ignoring the hours.
Easily Calculate Dates and Times with WPS Spreadsheet
WPS Spreadsheet fully supports all standard Excel date and time functions, including MAX, IF, and INT. You can seamlessly calculate lengths of stay, manage patient records, and organize booking data within a highly intuitive and free interface.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your existing .xlsx file containing patient or booking data.
- 2. Apply the Formula: Click on your target cell and type =MAX(1, B2-A2) to calculate the minimum one-day stay.
- 3. Drag to Autofill: Click and hold the small green square at the bottom-right corner of the cell, then drag it down to apply the formula to the rest of your dataset.

Frequently Asked Questions
Why does subtracting dates in Excel sometimes return a #VALUE! error?
This error occurs when the cells are formatted as text instead of dates, which means Excel cannot perform mathematical operations on them. Ensure both columns are highlighted, right-click, select 'Format Cells', and set them to the 'Date' format.
How do I exclude weekends from my length of stay calculation?
You can use the NETWORKDAYS function to calculate only working days. To ensure it still returns at least 1, wrap it in a MAX formula: =MAX(1, NETWORKDAYS(A2, B2)).
Can I use the DATEDIF function for this minimum one-day calculation?
Yes, DATEDIF can calculate the days between dates, but you still need to wrap it in a MAX statement to return 1 for same-day events. You would use the formula: =MAX(1, DATEDIF(A2, B2, "d")).




