Sub topic 3
Building a date with DATE
This chapter assumes you can enter formulas, use cell references such as A2, and apply a number format to a cell. It covers the DATE function, which builds a date from separate year, month, and day numbers.
Why build a date instead of typing one
Typing 3/15/2023 into a cell relies on Excel parsing your text using the computer's regional settings. The same entry can mean 15 March in one locale and fail or flip to a different date in another. DATE removes that guesswork. You pass three numbers, and Excel returns the serial number for that exact day.
The syntax is:
=DATE(year, month, day)All three arguments are numbers. They can be typed values, cell references, or the results of other formulas.
A first example
=DATE(2023,3,15)If the cell is formatted as General, it shows 45000. That is the serial number for 15 March 2023 in the 1900 date system. If Excel formats the cell as a date automatically, you see a date instead. The value stored in the cell is still 45000, and only the display differs.
Building dates from separate parts
DATE is most useful when the pieces come from different cells. Suppose a sheet holds year, month, and day in separate columns:
| Cell | Holds |
|---|---|
| A2 | 2024 |
| B2 | 3 |
| C2 | 1 |
This formula combines them into one real date:
=DATE(A2,B2,C2)The result is 1 March 2024. Because it is a real serial number, you can subtract it from another date, compare it, or pass it to functions such as EDATE, which later chapters cover.
Arguments that overflow
DATE does not reject a month or day outside the normal range. It rolls the extra into the next unit. This is a deliberate feature, and it also causes silent mistakes.
- A month of 13 becomes January of the following year, so
=DATE(2023,13,1)is 1 January 2024. - A month of 0 or a negative month moves backward, so
=DATE(2024,0,1)is 1 December 2023. - A day larger than the month length carries into the next month, so
=DATE(2024,2,30)is 1 March 2024, because February 2024 has 29 days. - A day of 0 returns the last day of the previous month, so
=DATE(2024,3,0)is 29 February 2024.
The last case gives a useful trick. To find the last day of any month without another function, ask for day 0 of the following month. Later chapters use EOMONTH for the same job, which is usually clearer to read.
The following sequence shows how a formula reaches a result:
Two-digit years and other pitfalls
The year argument has special handling. A value from 0 to 1899 is added to 1900, so =DATE(23,3,15) returns 15 March 1923, not 2023. A value from 1900 to 9999 is used as given. Always pass four-digit years so the result does not depend on this rule.
Also keep these points in mind:
- Pass numbers, not text. If a cell holds the text
"2024",DATEcan often convert it, but a value with stray spaces may produce#VALUE!. - A year below 0 or above 9999 returns
#NUM!. - Overflow is silent. If a month column contains 14 by mistake, you get a date in the next year with no warning. Validate inputs when the source data is not trusted.
Exercise
Cells A2, B2, and C2 hold 2024, 1, and 31. What does =DATE(A2,B2+1,C2) return, and why?
Show answer
It returns 2 March 2024. The month becomes 2 (February), but February 2024 has only 29 days, so day 31 overflows by two days into March. DATE does not stop at the end of February. EDATE, covered later, handles this case differently.