What this calculator does
The Add or Subtract Days Calculator finds the exact calendar date that falls a chosen number of days before or after any start date. Whether you need to know "what date is 90 days from today" or "what was the date 45 days ago," this tool gives you the answer along with the day of the week. It works for any Gregorian date and correctly handles month lengths, leap years, and year boundaries.
How to use it
Enter your start date (year, month and day), choose whether to add or subtract days, and type the number of days. The calculator returns the resulting date in YYYY-MM-DD form plus its weekday. It is a universal date tool — no country or calendar-specific assumptions beyond the standard Gregorian calendar.
The formula explained
Instead of juggling variable month lengths and leap years directly, the tool converts the start date into a Julian Day Number (JDN) — a single running count of days. Adding or subtracting N is then trivial integer arithmetic:
$$\text{JDN}_{out} = \text{JDN}(\text{start}) \pm N$$The result is converted back to a year, month and day. The weekday comes from \(\text{JDN} \bmod 7\). The underlying conversion uses
$$\text{JDN} = d + \left\lfloor\frac{153m+2}{5}\right\rfloor + 365y + \left\lfloor\frac{y}{4}\right\rfloor - \left\lfloor\frac{y}{100}\right\rfloor + \left\lfloor\frac{y}{400}\right\rfloor - 32045$$This approach is exact and avoids the rounding errors that plague naïve day-by-day loops.
Worked example
Start with 2024-01-01 and add 30 days. The JDN of 2024-01-01 is 2,460,311. Adding 30 gives
$$2{,}460{,}311 + 30 = 2{,}460{,}341$$which converts back to 2024-01-31. Because 2024 is a leap year, the calculation seamlessly accounts for January's 31 days. Adding one more day (31 total) would roll over to 2024-02-01.
Key Terms Explained
- Julian Day Number (JDN)
- A continuous count of whole days since noon Universal Time on 1 January 4713 BC (proleptic Julian calendar). Because every calendar date maps to a single integer, adding or subtracting days becomes simple integer arithmetic: convert the date to its JDN, add or subtract the offset, then convert back. This avoids manual handling of month lengths and leap years.
- Gregorian calendar
- The civil calendar used in most of the world today, introduced by Pope Gregory XIII in 1582. It defines a year of 365 days with a leap day added under specific rules, giving an average year length of 365.2425 days that closely tracks the solar year.
- Proleptic Gregorian calendar
- An extension of the Gregorian calendar applied to dates before its 1582 introduction. Calculators use it so that historical or very early dates follow the same consistent leap-year rules, ensuring uninterrupted JDN arithmetic across any era.
- Leap year
- A year containing 366 days (with 29 February). A Gregorian year is a leap year if it is divisible by 4, except for century years, which must also be divisible by 400. So 2000 and 2024 are leap years, but 1900 and 2100 are not.
- Weekday-from-modulo
- The day of the week derived directly from the JDN using modular arithmetic. Because the days of the week repeat every 7 days, computing \((\text{JDN} + 1) \bmod 7\) yields a value from 0 to 6 that maps to a weekday (with JDN 0 falling on a Monday). This lets the calculator name the weekday of any result date without a lookup table.
FAQ
Does it handle leap years? Yes. The Julian Day Number method inherently accounts for leap years and varying month lengths, so February 29 in leap years is handled correctly.
Can I cross over into a new year? Absolutely. Adding enough days will roll the result forward into the next year (or back into a previous one when subtracting), with no special action needed.
What calendar does it use? The proleptic Gregorian calendar, the standard civil calendar used worldwide today.