How to calculate date difference

A date difference can mean total elapsed days or a calendar interval in years, months and days. Choose the measurement first because the two answers describe the same span differently.

Open the date difference calculator

Elapsed days = later date − earlier date

Standard elapsed-time counting excludes the starting date. June 1 to June 2 is one day.

Calculate total elapsed days

For short ranges, count each midnight crossed. From March 28 to April 3:

  1. March 28 to March 31 is 3 days.
  2. March 31 to April 3 is 3 more days.
  3. The total elapsed difference is 6 days.

For long ranges, convert both dates to a serial day number or let calendar software handle month lengths and leap years. Do not assume every month has 30 days or every year has 365.

Inclusive versus exclusive counting

MethodJune 1 to June 2Typical use
Elapsed difference1 dayTime between dates
Include both dates2 daysDays appearing in a date range

Inclusive count is usually elapsed days + 1, provided the range is valid. Always state the convention when deadlines, bookings or billing are involved.

Calculate calendar years, months and days

Count forward from the earlier date using whole calendar units. From May 17, 2022 to August 25, 2024:

  1. May 17, 2022 to May 17, 2024 is 2 years.
  2. May 17 to August 17 is 3 months.
  3. August 17 to August 25 is 8 days.

The calendar difference is 2 years, 3 months and 8 days. This cannot be reconstructed reliably by dividing total days by 365 and 30 because calendar units vary in length.

Leap years and month ends

A leap year normally occurs when the year is divisible by 4, except century years not divisible by 400. Therefore 2024 and 2000 are leap years, while 2100 is not.

Month-end ranges also need an explicit convention. January 31 to February 28 may be described as 28 elapsed days or one calendar month under a last-day rule. Different systems can represent the calendar portion differently while agreeing on total days. Use total elapsed days when an unambiguous duration is required.

Use ToolPixels for the count

The free Date Difference Calculator returns elapsed days and a calendar difference between the dates you enter. It also helps avoid manual errors around leap days and unequal month lengths.

Enter dates without times. If time zones or exact hours matter, a date-only result is not sufficient.

Calculate the date difference