How-to recipes · Dates and times

How to calculate the number of days between two dates in Excel

Count the days between two dates by subtracting them or with DAYS, include both ends, count from today, and get weeks or months instead.

Beginner DAYS DATEDIF TODAY NETWORKDAYS ABS INT

How many days did the project take? How many days until the contract expires? How long has this invoice been unpaid? Counting days between two dates is one of the most useful date calculations, and in Excel it is simply a subtraction, because Excel stores every date as a number: the number of days since 1 January 1900. The details worth knowing are whether to include both the first and the last day, how to avoid the result being shown as a date, and how to count only working days.

The example data

A project with a start date in B2 (02 March 2026) and an end date in C2 (18 May 2026).

Subtract the dates (every version)

D2fx=C2-B2
ABCD
1ProjectStartEndDays
2Website redesign2026-03-022026-05-1877

Excel stores the dates as 46160 and 46083; the difference is 77. Make sure the result cell is formatted as General or Number.

Result: 77

The later date goes first. If the dates are the other way round, the result is negative; use ABS when you only care about the size of the gap: =ABS(C2-B2).

Watch out. If the result appears as a date such as 17-Mar-1900, Excel copied the date format from the input cells. The calculation is right; change the cell format to General (Home > Number Format > General, or Ctrl+Shift+~).

The DAYS function

DAYS (Excel 2013 and later) does the same subtraction but takes the end date first: =DAYS(C2,B2) returns 77. Its advantages are readability and that it also accepts dates written as text, such as =DAYS("2026-05-18","2026-03-02"). There is no difference in the result.

Include both the start and the end day

Subtraction counts the nights between the dates, not the calendar days on which work happened. A task from Monday to Friday is Friday - Monday = 4, but it covers 5 days. When both days count, as for hotel stays you charge per day, leave requests, or rental periods, add 1: =C2-B2+1 gives 78 for the project.

Days from or until today

Use TODAY as one of the dates and the result updates every day:

  • Days since an invoice date in B2: =TODAY()-B2.
  • Days left until a deadline in C2: =C2-TODAY(). A negative result means the deadline has passed.
  • Show a friendly message: =IF(C2<TODAY(),"Overdue by "&TODAY()-C2&" days",C2-TODAY()&" days left").

TODAY recalculates whenever the workbook opens, so the numbers always reflect the current date. For a report that must not change, type the reference date in a cell instead.

Weeks, months and years

UnitFormulaResult for the project
Complete weeks=INT((C2-B2)/7)11
Weeks with decimals=(C2-B2)/711.0
Complete months=DATEDIF(B2,C2,"m")2
Complete years=DATEDIF(B2,C2,"y")0

DATEDIF counts calendar months correctly; dividing the days by 30 does not, because months have 28 to 31 days. For a person's age, see How to calculate age in Excel.

Working days only

For business deadlines you usually want to exclude weekends and public holidays. NETWORKDAYS does that: =NETWORKDAYS(B2,C2) counts the Monday-to-Friday days between the dates, including both ends, and an optional third argument takes a list of holidays. The full recipe is in How to count working days between two dates in Excel.

Dates with times

If the cells contain a date and a time (for example from a ticket system), the difference has decimals: 2.75 means 2 days and 18 hours. Use =INT(C2-B2) for whole days, or format the result as [h]:mm to see the total hours and minutes. Converting a time difference into hours is covered in How to sum time over 24 hours in Excel.

Pitfalls

  • Text dates produce #VALUE! when subtracted. Check with =ISNUMBER(B2); convert them with How to convert text to a date in Excel.
  • Empty cells count as day 0 (in January 1900), so a missing end date gives a huge negative number. Guard with =IF(C2="","",C2-B2).
  • Wrong regional order. A date typed as 03/05 means March 5 or 3 May depending on your settings. Type unambiguous dates such as 2026-05-03.
  • 1904 date system. Workbooks created on old Macs may use dates counted from 1904. Differences between dates are still correct, but copying dates between workbooks shifts them by 4 years.
Tip. Dates are numbers: Dates and times: serial numbers, date math and working days explains the serial number system and why it makes date maths so easy.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 12 KB

More how-to recipes