Sheet Happens
Intermediate

Date calculations

8 minutes · 4 steps · free, no sign-up

Once you know a date is just a number, calculating with dates gets simple. How long is a project? When is an invoice due? How many working days are left? You will answer each with a short formula.

In this lesson you will
  • Count the days between two dates by subtracting
  • Count whole months or years with DATEDIF
  • Move a date forward with EDATE and find a month end with EOMONTH
  • Count working days with NETWORKDAYS
A1 fx

Click a cell and start typing. Enter edits, Tab moves right, arrows move, Delete clears.

Quick referenceQuick reference

=B2-A2                     days between
=DATEDIF(A2, B2, "M")      whole months ("Y" years, "D" days)
=EDATE(A2, 3)              same day, 3 months later
=EOMONTH(B2, 0)            last day of that month
=NETWORKDAYS(A2, B2)       Monday to Friday count

The key ideasSummary: Date calculations

Subtracting two dates gives the number of days between them, so a project from 12 January to 14 March is 61 days. When you need whole months or years, DATEDIF counts complete ones only: 12 January to 14 March is 2 whole months, not 2.07.

EDATE adds months and keeps the day where it can (and uses the month end when it cannot), EOMONTH jumps to the last day of a month, handy for billing and payroll, and NETWORKDAYS counts Monday to Friday, including both end dates.

Watch out forCommon mistakes

  • Getting a date back when you wanted a number. If a subtraction shows 01/03/1900, the answer cell was formatted as a date. Format it as a number instead.
  • Adding 30 for "a month". Months have different lengths. Use EDATE.
  • Reversing the dates in DATEDIF. The start must come first. A later start gives an error.
  • Forgetting bank holidays. NETWORKDAYS counts every weekday. It takes an optional list of holidays to leave out.

Next stepTry it in the real Google Sheets

DATEDIF works in Google Sheets and Excel, although Excel does not list it in its function menu. NETWORKDAYS.INTL lets you choose which days count as the weekend.