Find a course

Module 5: Text, Dates and Dynamic ArraysLesson 11 of 1212 min

Date and Time Functions

Do date math with serial numbers, calculate due dates with EDATE and EOMONTH, count working days with NETWORKDAYS and convert times to hours.

Step 1 of 11Learn

Dates are numbers in disguise

An accounts team needs to know which invoices are overdue, by how many days, and when next month's payments fall due. Every part of that is arithmetic, because Excel stores dates as numbers.

A date is a serial number: the count of days since January 1, 1900, which is day 1. January 1, 2026 is 46023. The cell shows 1/1/2026 only because it has a date format. Change the format to General and you'll see the number underneath.

This makes date math simple:

  • Days between two dates: =B2-A2
  • A date 30 days later: =A2+30
  • Days overdue: =TODAY()-C2, where C2 is the due date

Times are fractions of a day. Noon is 0.5, 6:00 AM is 0.25, and 1 hour is 1/24 ≈ 0.0417. So 3/15/2026 6:00 PM is stored as 46096.75.

When date formulas misbehave, it's usually because a "date" is actually text, often from an import or a regional format clash (is 03/04/2026 March 4 or April 3?). Text dates are left-aligned by default, and =ISNUMBER(A2) returns FALSE for them. DATEVALUE or Data > Text to Columns converts them into real dates.

Dates are serial numbers; times are fractions of a dayWhat the cell showsWhat Excel stores1/1/190011/1/2026460233/15/2026460963/15/2026 6:00 PM46096.7512:00 PM (noon)0.5

Step 2 of 11Practice · Work it out

A2 holds January 15, 2026 and B2 holds March 1, 2026. What does =B2-A2 return (in days)? 2026 is not a leap year.

Step 3 of 11Learn

Building and taking apart dates

Several functions create dates or pull pieces out of them:

  • TODAY() returns the current date; NOW() returns the current date and time. Both are volatile: they recalculate whenever the workbook changes, so an "age" or "days overdue" column is always current. To freeze today's date in a cell, press Ctrl+; instead.
  • DATE(year, month, day) builds a date from parts: =DATE(2026, 3, 15). It's the reliable way to create dates in formulas, because it doesn't depend on regional settings. It also rolls over sensibly: =DATE(2026, 13, 1) is January 1, 2027.
  • YEAR, MONTH and DAY extract parts: =MONTH(A2) returns 3 for any date in March.
  • WEEKDAY(date) returns 1 for Sunday through 7 for Saturday by default; =WEEKDAY(A2, 2) returns 1 for Monday through 7 for Sunday, which many find easier for "is it a weekend?" tests (result greater than 5).
  • TEXT(A2, "dddd") returns the day name, such as "Sunday".

Combining them answers common questions. First day of the month containing A2: =DATE(YEAR(A2), MONTH(A2), 1). Same day next year: =DATE(YEAR(A2)+1, MONTH(A2), DAY(A2)).

Step 4 of 11Learn

EDATE and EOMONTH: months are not all the same length

Adding 30 days isn't the same as adding a month. To move by whole months, use:

  • EDATE(start, months) returns the same day of the month, months later (or earlier, with a negative number). =EDATE("2026-01-15", 3) is April 15, 2026. If the day doesn't exist in the target month, EDATE uses the last day: =EDATE("2026-01-31", 1) is February 28, 2026.
  • EOMONTH(start, months) returns the last day of the month, months away. =EOMONTH("2026-01-15", 0) is January 31, 2026; =EOMONTH("2026-01-15", 1) is February 28, 2026.

EOMONTH solves many business rules:

  • Payment terms "end of month following": =EOMONTH(A2, 1)
  • First day of next month: =EOMONTH(A2, 0) + 1
  • Days in the month: =DAY(EOMONTH(A2, 0)) returns 28, 29, 30 or 31
  • Grouping by month: =EOMONTH(A2, 0) gives every March date the same value, March 31, which is a clean key for SUMIFS or a PivotTable.

Contract renewals, subscription billing and loan schedules all depend on adding months correctly. Using +30 drifts by a day or two each month and ends up visibly wrong within a year.

Adding "a month": +30 vs EDATE vs EOMONTH (2026)FormulaStart Jan 15Start Jan 31=A2+30Feb 14Mar 2=EDATE(A2,1)Feb 15Feb 28=EOMONTH(A2,0)Jan 31Jan 31=EOMONTH(A2,1)Feb 28Feb 28

Step 5 of 11Practice · Choose one

What does =EOMONTH(DATE(2026,1,10), 1) return?

Step 6 of 11Learn

Working days, ages and durations

Working days. NETWORKDAYS(start, end, [holidays]) counts weekdays between two dates, including both the start and end dates, and skips any dates listed in an optional holidays range. WORKDAY(start, days, [holidays]) goes the other way: the date that is a given number of working days after the start. A 10-business-day delivery promise from an order date in A2 is =WORKDAY(A2, 10, Holidays).

If your weekend isn't Saturday and Sunday, NETWORKDAYS.INTL and WORKDAY.INTL take a weekend code, for example 7 for Friday–Saturday.

Ages and tenure. DATEDIF(start, end, unit) returns complete years ("Y"), months ("M") or days ("D") between two dates. It's an old function that Excel doesn't list in autocomplete, but it works. Age in completed years: =DATEDIF(B2, TODAY(), "Y"). Dividing days by 365 instead drifts across leap years and can show someone as a year older a day early.

Fractions of a year. YEARFRAC(start, end) returns years as a decimal, such as 2.5, useful for prorating interest or bonuses.

For any of these, keep holiday lists in a named table so every formula uses the same calendar.

Step 7 of 11Try the calculator

Timesheet hours and pay

Excel stores times as fractions of a day, so hours = (end - start) * 24. Enter times as decimal hours (8:30 AM = 8.5, 5:15 PM = 17.25). The formula wraps past midnight like =MOD(B2-A2,1)*24, so a 22 to 6 night shift gives 8 hours.

Stored as fraction of a day
0.3646
Hours worked
8.75
Pay
192.5 $

Step 8 of 11Practice · Work it out

A project runs from Monday, March 2, 2026 to Friday, March 13, 2026, with no holidays. What does =NETWORKDAYS(DATE(2026,3,2), DATE(2026,3,13)) return?

Step 9 of 11Note

Step 10 of 11Practice · True or false

=A2+30 and =EDATE(A2,1) always return the same date.

Step 11 of 11Practice · What would you do?

What would you do?

HR wants an Age column that shows each employee's age in completed years, from the date of birth in B2, and stays correct every day. Which formula do you use?