How do I calculate how many days are between two dates?
Between leap years, months with 30 versus 31 days, and February doing whatever it wants, manual calendar math is a trap.
The short answer
Subtract the earlier timestamp from the later timestamp in milliseconds, divide by 86,400,000 (1000 × 60 × 60 × 24), and choose whether you are counting the end date inclusively.
Step 1: Decide on inclusive versus exclusive counting
If you leave on Monday and return on Wednesday, are you gone 2 days (nights) or 3 days (calendar days)? Establish that rule first.
Step 2: Account for leap years and month lengths
Thirty days hath September, April, June, and November. All the rest have thirty-one, save February alone.
Step 3: Filter business days if needed
Work deadlines usually exclude weekends and public holidays. The calculator on this site reports business days next to the raw total, counting weekends out. It does not know your local public holidays, so subtract those yourself.
Common mistakes
- Forgetting that daylight saving time shifts the duration by 1 hour, causing floor calculations to drop an entire day.
- Assuming every month is 4 weeks. Only February outside a leap year is exactly 28 days, and every other month runs 30 or 31.