Excel Date Functions

Excel stores dates as serial numbers behind the scenes, and its date functions let you retrieve today's date, pull out a year or month, and calculate the gap between two dates.

Getting the Current Date and Time

TODAY() returns the current date, and NOW() returns the current date and time. Neither function takes any arguments, and both are volatile, meaning they automatically refresh whenever the worksheet recalculates, such as when you open the file again the next day.

Example

=TODAY()

Breaking a Date into Year, Month, and Day

Because a date is really just a serial number formatted to look like a date, functions can extract individual parts of it. YEAR, MONTH, and DAY each take a single date and return the corresponding numeric component.

FunctionReturns
YEAR(date)The four-digit year, such as 2026.
MONTH(date)The month number, from 1 (January) to 12 (December).
DAY(date)The day of the month, from 1 to 31.

Example

=YEAR(A2)

Calculating the Gap Between Two Dates with DATEDIF

DATEDIF(start_date, end_date, unit) calculates the difference between two dates in whichever unit you choose: complete years, complete months, or complete days. It is a hidden function, meaning Excel does not show it in the formula autocomplete list, but it still works correctly when typed manually.

Example

=DATEDIF(A2,B2,"Y")
  • "Y" returns the number of complete years between the two dates.
  • "M" returns the number of complete months.
  • "D" returns the number of days.
  • "YM" returns the remaining months after subtracting whole years.
  • "MD" returns the remaining days after subtracting whole months.
Note: Because dates are serial numbers, you can add or subtract directly: =A2+30 gives a date 30 days after A2, and =B2-A2 gives the number of days between two dates without needing any special function.

Exercise: Excel Functions

What does the function =SUM(A1:A10) calculate?