sodcalculator

08 Everyday Math

Date Calculator in Excel: Formulas and Date Differences

Guide 08-0374 · Updated · Step by step

Excel can calculate the number of days between two dates, add or subtract days, and find dates a set number of months or years away. Enter valid dates in cells and use a formula such as =B2-A2 for elapsed days; the result is a number of days, not a special date-calculator display.

Choose the calculation you need

The right Excel formula depends on what “date calculator” means in your situation. For two dates, subtract the earlier date from the later date. To move forward or backward by a number of days, add or subtract that number. To calculate a date by calendar months or years, use EDATE or DATE, since months do not all have the same length.

  • Days between dates: =B2-A2
  • Date after a number of days: =A2+C2
  • Date before a number of days: =A2-C2
  • Date after a number of months: =EDATE(A2,C2)

In these examples, A2 and B2 contain dates and C2 contains a number. The subtraction result is the elapsed-day difference: it does not count both endpoints as separate days. For example, the interval from Monday to Tuesday is one elapsed day. If a task treats both the start and end dates as included, add 1 to the difference.

How Excel stores dates

Excel generally stores a date as a serial number: whole numbers represent days in its date system, and any fractional part represents a time within a day. A cell can display that serial value as a familiar date through number formatting. This is why subtracting two valid date values produces a number of days.

For example, if A2 is 10 March 2026 and B2 is 18 March 2026, =B2-A2 returns 8. Format the result cell as General or Number to see the day count. If the result cell is formatted as a date, Excel may display an unexpected calendar date instead. The calculation may be correct; the display format is not appropriate for a duration.

Excel workbooks can use different date systems, including the 1900 and 1904 systems. This is usually handled automatically, but copying date serials between workbooks using different systems can shift dates. Prefer copying actual date values or checking the workbook’s date-system setting if dates appear offset after a transfer.

Calculate days, weeks, and working days

For ordinary calendar days, subtraction is the simplest method. To express the result in weeks, divide by 7: =(B2-A2)/7. This can return a decimal when the span is not an exact number of weeks. To count only complete weeks, use =INT((B2-A2)/7) for nonnegative date differences.

When weekends should be excluded, use NETWORKDAYS. For dates in A2 and B2, =NETWORKDAYS(A2,B2) counts workdays inclusively, with Saturday and Sunday treated as weekends by default. That inclusivity is important: if both dates fall on weekdays, the formula counts both the first and last date. To exclude holidays, place holiday dates in a range such as H2:H10 and use =NETWORKDAYS(A2,B2,H2:H10).

For work schedules with a weekend pattern other than Saturday and Sunday, Excel provides NETWORKDAYS.INTL. Its weekend argument can specify which days are weekends. Check the function’s help in your Excel version for the supported weekend codes or text pattern; a mistaken pattern can change the count.

Add months and years correctly

Adding a fixed number of days is not the same as adding calendar months. A month may have 28, 29, 30, or 31 days, so =A2+30 means exactly 30 days later, not one month later. Use =EDATE(A2,1) for one calendar month after A2, or =EDATE(A2,-3) for three calendar months earlier.

If the target month does not have the original day number, EDATE returns the last day of the target month. For example, one month after 31 January is the last day of February. This behavior is useful for recurring monthly dates, but it may not match a rule that requires a particular business day or a fixed number of days.

To add years while retaining a particular month and day, use =DATE(YEAR(A2)+C2,MONTH(A2),DAY(A2)). Dates involving 29 February need a policy decision: the next year may not be a leap year, and Excel’s date construction normalizes invalid month/day combinations. If the result has legal, contractual, or operational importance, confirm the intended rule rather than assuming “one year” always means the same thing.

Use DATEDIF for completed periods

DATEDIF can calculate completed years, months, or days between two dates. For example, =DATEDIF(A2,B2,"Y") returns the number of complete years, while =DATEDIF(A2,B2,"M") returns complete months. The start date must not be later than the end date, or the formula returns an error.

DATEDIF is useful for age-like or tenure-like calculations, but it does not describe every possible notion of a month or year. The unit "MD", which attempts to return the day difference after ignoring months and years, has documented limitations and can give unexpected results in some date combinations. For transparent calculations, use subtraction for elapsed days and clearly specified YEAR, MONTH, and DAY logic for a particular business rule.

Common errors and checks

  • A formula shows a date instead of a number: change the result cell’s number format to General or Number.
  • A date is treated as text: check that Excel recognizes it as a date. A value imported as text may need conversion; changing its appearance with formatting alone does not make text a date.
  • The result is negative: the end date may be earlier than the start date. Reverse the cell references if that is unintended; do not hide the issue by taking an absolute value unless direction truly does not matter.
  • Dates are ambiguous: entries such as 03/04/2026 can mean different days under different regional settings. Use unambiguous entry methods or verify the displayed date after entry.
  • A result is off by one: decide whether the question asks for elapsed days or an inclusive count. Subtraction gives elapsed days; adding 1 includes both endpoints when appropriate.

Also check for times hidden in date cells. Because Excel stores times as fractions of a day, subtracting date-time values can produce a fractional day. Format the result to reveal decimals, or use =INT(B2)-INT(A2) when the goal is to ignore times and compare calendar dates only.

Frequently Asked Questions

How do I calculate the number of days between two dates in Excel?
Put the earlier date in A2 and the later date in B2, then enter =B2-A2. Format the result as General or Number to display the elapsed days.

How do I add 30 days to a date?
If the starting date is in A2, use =A2+30. This adds exactly 30 days, which may land in a different calendar-month position than adding one month with =EDATE(A2,1).

How do I count weekdays between dates?
Use =NETWORKDAYS(A2,B2) for a count that includes weekdays at both endpoints and excludes Saturday and Sunday. Add a holiday range as the third argument when needed.

Why does subtracting dates show another date?
The result cell is probably formatted as a date. Change its number format to General or Number; date subtraction normally returns a count of days.

Does Excel count the start date in a date difference?
Subtraction measures elapsed days, so the start date is not counted as an additional full day. For an inclusive count of both endpoint dates, use =B2-A2+1 when that convention fits the task.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Everyday Math bed →