How to Calculate the Number of Days Between Two Dates
Calculating the days between two dates requires handling month lengths, leap years, and whether to include the endpoints. This guide explains the manual method and the fastest tool-based approach for any date range.
Choosing Inclusive or Exclusive Counting
Before calculating, decide whether to include the start date, the end date, both, or neither in your count. The choice depends on what you are measuring. For elapsed time (how many days have passed), count the end date but not the start date. For duration (how many days a period spans), count both endpoints.
A hospital stay beginning March 1 and ending March 5 represents 4 nights (exclusive count) but 5 days of hospitalization (inclusive count). A loan period beginning January 1 and ending December 31 is 364 days of interest accrual (exclusive) but covers 365 calendar days (inclusive). Neither answer is wrong; the correct one depends on how the period is defined.
Spreadsheet functions like DAYS in Excel use exclusive counting by default — they count from the day after the start date through and including the end date. When interpreting calculator results, verify which convention was used and adjust if necessary for your application.
Step 1 – Break the Range Into Complete Months
For manual calculation, the most organized approach is to break the date range into three segments: the partial month at the start, the complete months in the middle, and the partial month at the end. Calculate each segment separately and then sum them.
Suppose the range is January 10 to April 25. The first segment is the remaining days in January after the 10th: January has 31 days, so 31 minus 10 gives 21 days. The second segment is the complete months of February and March: February has 28 days (or 29 in a leap year) and March has 31 days, giving 59 days. The third segment is the days elapsed in April: 25 days.
Adding the three segments: 21 plus 59 plus 25 equals 105 days (using exclusive counting, not including January 10 itself). Verify by checking that January 10 plus 105 days lands on April 25, which it does.
Step 2 – Account for Leap Years
A leap year occurs when the year is divisible by 4, except for years divisible by 100 that are not also divisible by 400. The year 2024 is a leap year (divisible by 4 and not by 100). The year 2100 will not be a leap year (divisible by 100 but not by 400).
When your date range spans one or more February months, check whether each February falls in a leap year. If it does, that February has 29 days instead of 28. Adjust your segment total accordingly. For a date range spanning several years, you may need to check multiple February months.
A practical shortcut is to use January 1 as your reference point. Count the number of days from January 1 of the start year to the start date (the day-of-year number), and count from January 1 of the end year to the end date. Then add the days in each complete year between the two years, treating leap years as 366 days.
Using Spreadsheets for Date Differences
In Excel and Google Sheets, subtract one date from another to get the number of days between them. Entering =B1-A1, where A1 contains the earlier date and B1 contains the later date, returns a number. Format the result cell as a number (not as a date) to see the day count rather than a date.
The DAYS function provides the same result with explicit syntax: =DAYS(end_date, start_date). It returns the number of days from the start date to the end date, using exclusive counting (not including the start date but including the end date).
For years and months breakdowns, use the DATEDIF function: =DATEDIF(start_date, end_date, unit), where unit is 'D' for days, 'M' for complete months, or 'Y' for complete years. DATEDIF is an undocumented but functional formula available in both Excel and Google Sheets that simplifies complex date difference calculations.
Verifying Your Result
Verify a days-between-dates calculation by counting forward from the start date by the number of days you calculated and confirming you arrive at the end date. If you calculated 105 days from January 10, counting forward 105 days should land on April 25. Work through a few key milestones: January 10 plus 21 days is January 31, plus 28 days is February 28, plus 31 days is March 31, plus 25 days is April 25.
Cross-check using an online date calculator. Enter the same start and end dates and compare the result to your manual calculation. Discrepancies of exactly 1 day usually indicate a boundary inclusion difference (one method counts the start date, the other does not). Larger discrepancies suggest a calculation error or a missed leap year.
For critical applications like legal deadlines, tax dates, or financial interest calculations, use multiple tools and methods to confirm the result. Document which inclusion convention you used so that anyone auditing the calculation can reproduce it and verify the answer independently.
