How to add or subtract days from a date (without spreadsheet errors)
Adding 30 days to a date seems like the most basic operation possible. But Excel sometimes gives weird results, manual counting is error-prone, and "30 days" can mean different things depending on context. Here's how to do it correctly.
For computing exact "X days from now" or "X business days from then," the add/subtract calculator handles it.
The basic mechanic
To add days to a date:
1. Start with date D
2. Add N days
3. The result is D + N days
For "5 days from May 21, 2026": May 26, 2026.
For programming or spreadsheets:
Excel/Google Sheets: `=A1+5` where A1 contains a date. This works for calendar days.
Python: `from datetime import timedelta; date + timedelta(days=5)`
JavaScript: `new Date(date.getTime() + 5 24 60 60 1000)`
SQL (PostgreSQL): `date + INTERVAL '5 days'`
These all give consistent results for simple cases.
When it gets tricky
Adding months (not just days)
"Add 3 months from May 21" → August 21. Easy.
But: "Add 1 month from January 31"?
- Approach 1: February 28 (or 29 in leap year) — round to last day of next month
- Approach 2: March 3 (or March 2) — keep going past month boundary
- Approach 3: throw an error — January 31 + 1 month is undefined
Different libraries pick different conventions. The add/subtract calculator uses the "round to last day" convention.
Adding years
"Add 2 years from February 29, 2024 (leap year)" → February 29, 2026 (not a leap year).
Result: February 28, 2026 (round down) or "no such date" (error).
Spreadsheet calculation issues
Excel uses a date system that starts from January 1, 1900 (numerically 1). Various quirks:
- Excel believes 1900 was a leap year (it wasn't; 1900 was divisible by 100 but not 400). This causes a 1-day error for dates before March 1, 1900. Most modern users don't care.
- Excel's date type can confuse other systems. CSV exports often have date format issues.
For accuracy in spreadsheets:
- Use `=DATE(year, month, day)` for explicit construction
- Use `=DATEDIF(start, end, "d")` for duration in days
- Use `=WORKDAY(start, days)` for business-day-aware addition
Adding negative days (subtraction)
To subtract days, just add a negative number. "May 21 minus 7 days" = May 14. Most tools handle negatives correctly.
For periods spanning calendar boundaries:
- Subtracting from January 5 by 10 days → December 26 (previous year)
DST shifts
Adding "1 day" across a DST shift:
- Calendar interpretation: same date, next day. 1 calendar day.
- Time interpretation: 24 hours of UTC time. May land 1 hour earlier or later in local time.
For most date math, calendar days are what you want. The add/subtract calculator handles both interpretations.
Common scenarios
Project deadlines
"Submit proposal within 30 days":
- Calendar days: simple add of 30 days
- Business days: skip weekends and holidays (different calculator)
Contract terms
"Notice period: 60 days":
- Add 60 calendar days from today
- Watch for weekend/holiday alignment of the deadline
Pregnancy due date
"Due date is 280 days from LMP":
- Add 280 days
- Standard medical calculation
- Result: usually a date in next year
Birthday math
"How old will I be in 6 months?":
- Add 6 months to current date
- Compare with birth date
- Account for leap years
Travel planning
"My visa expires 30 days after entry":
- Add 30 days from entry date
- Plan to leave or extend before that date
Tools that help
Browser-based:
- The add/subtract calculator — quick and clear
- timeanddate.com date calculator
- calculator.net date arithmetic
Programming:
- Most languages have date arithmetic; just be careful with month/year boundaries
- Use libraries like Luxon, day.js (JavaScript), or zoneinfo (Python) for time-zone-aware math
Spreadsheets:
- Excel/Google Sheets handle simple date math correctly
- Use DATE(), DATEDIF(), WORKDAY() functions for explicit math
- For business days, use NETWORKDAYS()
Common mistakes
1. Counting from "today" with confusion about whether today counts.
"Pay within 30 days" — does day 1 = today or tomorrow? Be specific.
2. Mixing calendar days and business days.
"30 business days" is 6 weeks (30 weekdays = 6 weeks of 5). "30 calendar days" is just over 4 weeks. Different.
3. Time zone confusion.
"Due May 21 at midnight EST" is different from "Due May 21 at midnight UTC." Specify time zone.
4. Leap year missed.
"6 months from today" might land on February 29 (if you're 6 months before in a leap year). Be aware.
5. Month-end edge cases.
"1 month from January 31" is conventionally February 28 (or 29). Some software gives different results.
Specific recipes
"Find the last day of next month"
Most tools support this:
- Python: `date.replace(day=1) + timedelta(days=32)` then `replace(day=1)` and `subtract day=1`
- Excel: `=EOMONTH(today(), 1)` returns last day of next month
"Find the date 90 days before some target date"
Subtract:
- Python: `target_date - timedelta(days=90)`
- Excel: `=target_date - 90`
"Find the next business day after some date"
Use a business-day-aware tool:
- Python with workalendar library: `Calendar.addworkingdays(start_date, 1)`
- Excel: `=WORKDAY(start_date, 1)`
- The business days calculator
"Days remaining in current year"
- Python: `date(today.year, 12, 31) - today` gives a timedelta
- Excel: `=DATE(YEAR(TODAY()), 12, 31) - TODAY()`
"First Monday of next month"
Trickier. Most date libraries can do this with helper functions. Or manually: find first day of next month, then add days until you hit Monday.
When you need explicit time
For date+time math (not just dates):
- "Add 5 hours 30 minutes to current time"
- "Subtract 90 minutes from event time"
These work the same way:
- Python: `datetime.now() + timedelta(hours=5, minutes=30)`
- JavaScript: `new Date(date.getTime() + 5.5 3600 1000)`
- SQL: `now() + INTERVAL '5 hours 30 minutes'`
Remember: "1 day" in time math is 86,400 seconds. Across DST shifts, this can be 1 hour off in local time.
The "exclusive vs inclusive" trap
When counting "the next 30 days":
Inclusive: today is day 1, day 30 is 29 days from today. (Often used for legal "within 30 days" language.)
Exclusive: today is day 0, day 30 is 30 days from today. (Standard arithmetic.)
For contracts and deadlines, be specific. "Due 30 days from contract date" is ambiguous. "Due on 30th calendar day after contract date" is clearer.
FAQ
Why does Excel sometimes give weird date results?
Mostly when you're operating near month boundaries (Feb 28/29, end of months). Excel uses a date number system; arithmetic is correct but display can be confusing.
Should I use calendar days or business days?
Depends on context. For legal/contract terms, often business days. For simple counting, calendar days. Use whichever the contract specifies.
What if my date crosses DST shifts?
Calendar arithmetic doesn't change. "5 days from May 21" is May 26 regardless of DST. If you need precise hour math, use UTC.
How do I handle leap years?
Modern date libraries handle leap years correctly. February 29 is the main edge case. Test your code with February 29 to verify.
What's the right way in JavaScript?
Use a library (date-fns, day.js, Luxon) that handles edge cases correctly. Native `Date` is OK for simple cases.
Can I calculate "every Friday" from a date?
Yes — find the next Friday, then add 7 days repeatedly. Most date libraries support this with a "next weekday" helper.
Bottom line
Adding days to a date is simple in most cases, with edge cases around month boundaries, leap years, and DST shifts. Use date-aware libraries or the add/subtract calculator for accurate results. Be specific about whether you mean calendar days or business days.