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. You should also know from the earlier chapters that Excel stores a date as a serial number, a count of days. The DATE function is the safest way to create that number from separate year, month, and day values.
Why build dates instead of typing them
You can type 3/15/2023 into a cell and Excel will usually convert it to a date. The result depends on the computer's regional settings. 3/4/2023 is 4 March on one machine and 3 April on another. A typed date inside a formula, such as "3/15/2023", is text that Excel must interpret each time, and the interpretation can differ between users.
DATE takes three numbers and returns the serial number for that calendar day. It does no text parsing, so the result is the same on every machine.
=DATE(2023,3,15)With the cell formatted as General, this shows 45000. With a date format, it shows 15 March 2023. The formula returns the same value in both cases, and only the display changes.
Syntax and argument rules
=DATE(year, month, day)All three arguments are required, and each should be a number. Cell references and the results of other functions work as arguments.
=DATE(A2,B2,C2)If A2 holds 2024, B2 holds 7, and C2 holds 4, the result is 4 July 2024 (serial 45477). Excel truncates decimals without rounding, so DATE(2024,3.9,1) returns 1 March 2024, not 1 April.
Numeric text such as "2024" is converted to a number. Text that is not numeric, such as "March", causes a #VALUE! error.
How Excel reads the year
The year argument has special rules in the 1900 date system:
| Year argument | What Excel does | Example result |
|---|---|---|
| 1900 to 9999 | Uses the value as given | `DATE(2024,1,1)` is 1 Jan 2024 |
| 0 to 1899 | Adds 1900 to the value | `DATE(24,3,15)` is 15 Mar 1924 |
| Negative, or 10000 and above | Returns `#NUM!` | `DATE(10000,1,1)` is `#NUM!` |
The middle row is a common source of silent errors. A two-digit year such as 24 does not mean 2024. It means 1924. If your source data has two-digit years, add the century yourself, for example DATE(2000+A2,B2,C2).
The 1904 date system has different year rules and a different starting point. The chapter on date systems covers it. The examples here use the 1900 system.
Month and day overflow
DATE does not reject a month above 12 or a day above the month's length. It carries the extra into the next larger unit. This is the most useful property of the function.
A good model is that DATE finds the first day of the given year and month, then adds day - 1 days. Months outside 1 to 12 first shift the year.
The block above is only a placeholder to keep the order of ideas. The real diagram follows.
Month overflow
| Formula | Result | Serial |
|---|---|---|
| `=DATE(2023,14,1)` | 1 Feb 2024 | 45323 |
| `=DATE(2024,13,1)` | 1 Jan 2025 | 45658 |
| `=DATE(2024,0,1)` | 1 Dec 2023 | 45261 |
| `=DATE(2024,-1,1)` | 1 Nov 2023 | 45231 |
Month 0 means December of the previous year. Month -1 means November of the previous year, and so on.
Day overflow
=DATE(2024,2,30)February 2024 has 29 days, so day 30 carries over to 1 March 2024 (serial 45352). Compare this with EDATE, covered later in this tutorial, which stops at the end of the month instead of carrying over. DATE has no such clamping.
Day 0 and negative days move backward from the first of the month:
=DATE(2024,3,0)This returns 29 February 2024 (serial 45351), the day before 1 March. Day -1 would return 28 February. Day 0 is a compact way to get the last day of a month, though EOMONTH does the same job more clearly.
Taking dates apart and putting them back
DATE pairs with YEAR, MONTH, and DAY, which extract the three parts of a date. You can change one part and rebuild.
Assume A2 holds 15 March 2024.
=DATE(YEAR(A2)+1,MONTH(A2),DAY(A2))This returns 15 March 2025. The year moved forward and the month and day stayed the same.
The overflow rules matter when the target date does not exist. If A2 holds 29 February 2024, the same formula asks for 29 February 2025. That day does not exist, so Excel carries it over and returns 1 March 2025. Whether that is acceptable depends on your use. A contract anniversary might need 28 February instead.
Other common rebuilds:
=DATE(YEAR(A2),MONTH(A2),1)First day of A2's month.
=DATE(YEAR(A2),MONTH(A2)+1,1)First day of the following month. When A2 is in December, month 13 rolls into January of the next year without any extra logic.
=DATE(YEAR(A2),12,31)Last day of A2's year.
Converting split or text values
Data exports often store dates as digits without separators, such as 20240315 in A2. If A2 is text or a number, you can slice it and let DATE assemble the result.
=DATE(LEFT(A2,4),MID(A2,5,2),RIGHT(A2,2))This returns 15 March 2024 (serial 45366). LEFT, MID, and RIGHT return text, and DATE converts numeric text to numbers. If A2 holds a number rather than text, LEFT and the other text functions still work, because Excel converts the number to text first.
This approach is more reliable than DATEVALUE on ambiguous strings. You decide which characters are the year, month, and day, so no regional setting can change the meaning.
Checking the result
Because DATE returns a serial number, the cell may display a number such as 45366 instead of a date. Excel often applies a date format automatically when the formula contains DATE, but not always, especially when the cell was previously formatted as General or Text. Check these causes in order:
- If the cell shows a serial number, apply a date format. The value is correct.
- If the cell shows the formula text instead of a result, the cell is formatted as Text. Change it to General and re-enter the formula.
- If the cell shows
#VALUE!, one argument is non-numeric text or an empty string. Test each argument on its own. - If the cell shows
#NUM!, the year is negative or above 9999, or the final date falls outside the supported range. - If the date is in the wrong century, the year was below 1900 and Excel added 1900.
Subtracting built dates
Since DATE returns plain numbers, you can combine it with the arithmetic from the previous chapter:
=DATE(2024,3,1)-DATE(2024,1,1)This returns 60 because February 2024 has 29 days. You can also add days directly: =DATE(2024,1,31)+30 returns 1 March 2024 (serial 45352).
Exercise
Cell A2 holds the date 31 December 2023. Write a formula that returns the first day of the following month using DATE, YEAR, and MONTH, and state the result as a date and as a serial number. Then say what =DATE(2024,3,0) returns and why.
Show answer
Use =DATE(YEAR(A2),MONTH(A2)+1,1). MONTH(A2) is 12, so the month argument is 13. DATE carries it into January of the next year and returns 1 January 2024, serial 45292. =DATE(2024,3,0) returns 29 February 2024 (serial 45351). Day 0 means one day before the first of March, and 2024 is a leap year.
Exercise
A2 holds the text 20240229. What does =DATE(LEFT(A2,4)+1,MID(A2,5,2),RIGHT(A2,2)) return, and why might that be a problem for a yearly anniversary?
Show answer
It asks for 29 February 2025, which does not exist, so DATE carries the extra day into March and returns 1 March 2025. For an anniversary, you may want 28 February instead, so you would need an extra check or a function that clamps to month end, such as EDATE with 12 months.