Measuring Time Between Two Dates
A full date difference can be expressed multiple ways: total days (simplest), or broken down into years, months, and days (more human-readable). The years-months-days breakdown is trickier than it looks: it must account for varying month lengths. The standard algorithm: subtract the years first, then the months, adjusting the day if the end day is less than the start day by borrowing from the preceding month. This is how your age is calculated — you're not 'exactly 30.5 years old'; you're '30 years, 6 months, and some days' based on calendar counting.
Applications of date differences: age verification (are you 18+?), bond accrual (Actual/360 or Actual/365 day-count conventions in finance), loan term calculation, subscription expiry, and medical follow-up scheduling. The Gregorian calendar's irregular month lengths mean two events separated by 'one month' may be 28, 29, 30, or 31 days apart.
Date Difference in Multiple Units
| Difference | Days | Hours | Minutes |
|---|---|---|---|
| 1 week | 7 | 168 | 10,080 |
| 1 month (avg) | 30.44 | 730.5 | 43,829 |
| 1 quarter | 91.31 | 2,191 | 131,487 |
| 1 year (avg) | 365.25 | 8,766 | 525,960 |
| 1 decade | 3,652.5 | 87,660 | 5,259,600 |
| Century (with leap) | 36,524.25 | 876,582 | 52,594,920 |
