Excel Supreme

Excel track · Exercise 71 of 86 Paid

DATE: build a date from parts

Build a real date from three numbers and let DATE roll the overflow.

Intermediate

Invoice dates split into year, month and day columns

Read-only data · screen 1 of 2 · answer in E2

Column E wants the raised date as a real date number built from the year, month and day in B2:D2, so start with INV-2001 in E2.

ABCDE
1InvoiceYearMonthDayDate
2INV-2001202431
3INV-20022024415
4INV-20032024531

Download this grid (.xlsx) Two tabs: the grid you see, and the answer.

E2

What it does

A date in Excel is a serial number: the count of days since the end of 1899, with 1 January 1900 as day 1. The grid stores that serial, and a formatted date is only what the cell draws. DATE builds the serial from three ordinary numbers, a year, a month and a day, and hands back a real date that sorts and subtracts.

The first screen wants 1 March 2024 in E2, which is serial 45352 built from 2024, 3 and 1. The second asks for the first day of April, so the month argument holds B2+1. DATE rolls the parts over instead of returning an error: month 13 is January of the next year, and day 0 is the day before the first.

That behaviour saves a table of month lengths. The first of next month is the current month plus one, and the last day of this month is day zero of the next. Expressions work in any part, which is how B2+1 becomes April.

Syntax

=DATE(year, month, day)

Worked example

On Invoice dates split into year, month and day columns, =DATE(B2,C2,D2) returns 45352.

=DATE(B2,C2,D2)

Common errors

Error codes for DATE, and how a date is stored as a number
ErrorWhat it means and how to fix it
#VALUE!A part is text that does not read as a number, so DATE has nothing to build the serial from.
#NUM!A negative year, or parts that push the result past 31 December 9999, fall outside the serials Excel holds.
Wrong monthA month built as B2+2 rolls into the following month, so 1 May appears where 1 April was asked for.

At work

A finance export with the year, month and day in three columns, turned into one date column the ledger can sort and age.