Guides

How Do I Calculate the Number of Days Between Two Dates?

Learn how to calculate the number of days between two dates by hand: subtract day numbers within a month, work back to January 1, and add full calendar years.

Miryori Editorial Team2 min read
Open the calculator

When you need the day count by hand rather than from a calculator, the method changes with how far apart the dates are. A same-month pair is a single subtraction; dates in different months or years need a running total of days.

To calculate the number of days between two dates by hand, first decide whether the end date counts. For dates in the same month and year, subtract the smaller calendar day from the larger. For dates in different months, count the days from January 1 to each date and subtract. When the dates span years, add the full calendar years between them. Add one day if the end date is included.

What is the formula for counting days by hand?

The general approach reduces every date to a day-of-year total, then combines those totals with the whole years in between:

days=day-of-year(end)−day-of-year(start)+full years×365+include end date\text{days} = \text{day-of-year}(\text{end}) - \text{day-of-year}(\text{start}) + \text{full years} \times 365 + \text{include end date}

For dates in one month the day-of-year terms collapse to the two calendar day numbers. Each worked example below excludes the end date, so add 1 to include it.

Which day-count cases does the source cover?

Three cases cover every pair of dates, from a single subtraction to a multi-year span:

Case Method Source example Days (end excluded)
Same month and year Subtract the calendar day numbers April 4 to April 17, 2022 (17−417 - 4) 13
Same year, different months Days from January 1, then subtract May 17 to July 8, 2022 (189−137189 - 137) 52
Different years Partial start year + full years + partial end year September 17, 1997 to December 1, 1999 805

Worked example: May 17 to July 8, 2022

Work both dates back to January 1, 2022. January and March have 31 days, April has 30, and February has 28:

  • January 1 to May 17: 31+28+31+30+17=13731 + 28 + 31 + 30 + 17 = 137 days;
  • January 1 to July 8: 31+28+31+30+31+30+8=18931 + 28 + 31 + 30 + 31 + 30 + 8 = 189 days;
  • Difference: 189−137=52189 - 137 = 52 days.

So May 17 and July 8, 2022 are 52 days apart with the end date excluded, or 53 days if you include it.

How do I count days across multiple years?

Split the span into three pieces: the tail of the start year, the complete calendar years between, and the head of the end year. For September 17, 1997 to December 1, 1999, the source gives 105 days from September 17 to December 31, 1997, or 106 with the end date included; 334 days from January 1 to December 1, 1999; and one complete calendar year (1998) contributing 365 days. The total is 106+334+365=805106 + 334 + 365 = 805 days.

FAQ

Why do the examples exclude the end date?

Excluding the end date is the counting convention used throughout the source examples. If your task needs the end date counted, add one day to any result here.

Do I need to check for leap years?

Yes. The running totals depend on February having 28 days, or 29 in a leap year, so a leap day inside the span changes the answer by one.

What if both dates fall in the same month?

You can skip the day-of-year totals entirely and subtract the two calendar day numbers, as in April 4 to April 17, 2022.

References

  • Omni Calculator, "Number of Days Calculator": hand-counting methods and worked date examples.
  • Gregorian calendar conventions for month lengths and leap years.
Calculator

Number of Days Calculator

Calculate Number of Days with practical everyday formulas, interactive references and step-by-step results. Free, fast and private.

Open the calculator