Sub topic 1
Dates are numbers: the serial number model
Excel does not store a date as text like "15 March 2023". It stores a plain number and applies a display format to it. This idea explains most date behavior in Excel: why you can subtract two dates, why a date sometimes shows up as 45000, and why a "date" that is really text breaks your formulas. The rest of this tutorial (TODAY, EDATE, EOMONTH, DATEDIF) builds on this model.
Prerequisites
This chapter assumes you can already do the following:
- Enter and edit formulas in Excel cells.
- Use basic cell references such as
A2. - Apply a number format to a cell, for example through Format Cells or the Number group on the Home tab.
You do not need any date functions yet. This chapter introduces DATE only as far as needed to create test values.
The model: a date is a count of days
Excel keeps a running count of days. In the default 1900 date system, the serial number 1 is 1 January 1900, 2 is 2 January 1900, and so on. Each day adds exactly 1. A date's serial number is its position in that count.
| Serial number | Date it represents |
|---|---|
| 1 | 1 January 1900 |
| 36526 | 1 January 2000 |
| 44927 | 1 January 2023 |
| 45000 | 15 March 2023 |
| 45292 | 1 January 2024 |
| 2958465 | 31 December 9999 (the last date Excel supports) |
Two consequences follow directly:
- Dates are integers, and time is the fractional part. The whole-number part counts days. The decimal part is the time of day (covered below).
- Dates earlier than 1 January 1900 are not dates to Excel. Entering
1/1/1850gives you text, not a serial number. Negative serial numbers are not valid in the 1900 system.
Format versus value
A cell has two separate properties:
- The stored value, which is the number.
- The number format, which controls how that number is displayed.
Changing the format never changes the stored value. It only changes what you see.
You can see this yourself. Enter this formula in a cell formatted as General:
=DATE(2023,3,15)Excel usually notices that DATE returns a date and applies a date format to the cell automatically. To see the underlying number, change the cell's format to General. The cell then shows 45000. Change it back to a date format and the cell shows a date again. The value was 45000 the whole time.
The shortcut Ctrl+Shift+~ applies General format. Ctrl+Shift+# applies a day-month-year date format.
How to tell a real date from text
A typed value that looks like a date is only a date if Excel converted it to a number. Three quick checks:
- Alignment. By default, numbers (including dates) align right and text aligns left. A left-aligned "date" is probably text.
- Format test. Switch the cell to General. A real date turns into a number. Text stays unchanged.
- Formula test.
ISNUMBERreturns TRUE for real dates:
=ISNUMBER(A2)Text dates are covered fully near the end of this tutorial. For now, remember that a date function can only work on a number.
Formatting does not round or shorten the value
Applying a format such as mmm yyyy shows only "Mar 2023", but the cell still holds the full serial number. If A2 holds 45000 and you format it as mmm yyyy, then =A2+1 still returns 45001, shown as 16 March 2023 once you give it a day-level format. The month-only display is cosmetic.
Building a test date with DATE
Typing dates by hand depends on your regional settings. 3/4/2023 is 3 April in many countries and 4 March in the United States. The DATE function avoids that ambiguity because you give it the year, month, and day as separate numbers:
=DATE(year, month, day)For example, =DATE(2023,3,15) always returns serial 45000, regardless of locale. This tutorial uses DATE for examples because the result is the same on every machine. A later chapter covers DATE in more detail, including how it handles out-of-range months and days.
Date arithmetic follows from the model
Because a date is a number, ordinary arithmetic works on it:
- Adding a number moves a date forward by that many days.
- Subtracting a number moves it backward.
- Subtracting one date from another gives the number of days between them.
=DATE(2024,3,1)-DATE(2024,1,1)This returns 60. January has 31 days and February 2024 has 29 (2024 is a leap year), so 31 + 29 = 60. Excel handled the leap year because the serial numbers already account for it. You never add the month lengths yourself.
Adding days works the same way. If A2 holds 15 March 2023, then =A2+30 returns 14 April 2023 (serial 45030).
The result's format may surprise you
Excel often guesses the result format from the inputs. Two different outcomes cause confusion:
- Date plus number gives a date, and Excel usually formats it as a date.
- Date minus date gives a day count, but Excel sometimes formats the result as a date as well. You then see something like
01/03/1900instead of60.
If a subtraction shows a strange date near 1900, the value is correct. The format is wrong. Set the cell to General or Number and you will see the day count. A result of 60 displayed as a date is "29 February 1900" or "1 March 1900" depending on the system quirks described below. This is the same cause as the "wrong-looking" results most new users report.
Time of day is a fraction of a day
If one whole unit is one day, then part of a day is a decimal. Excel stores time of day as the fractional part of the serial number:
| Time | Fraction of a day |
|---|---|
| 00:00 (midnight) | 0 |
| 06:00 | 0.25 |
| 12:00 (noon) | 0.5 |
| 18:00 | 0.75 |
| 23:59:59 | about 0.99999 |
So the serial number 45000.5 means 15 March 2023 at 12:00. A cell showing only a date may still contain a time fraction that the format hides. Two cells that both display 15 March 2023 can hold different values, 45000 and 45000.5, and a comparison such as =A2=B2 returns FALSE.
Two formulas separate the parts:
=INT(A2)This returns the whole-day part (the date at midnight).
=MOD(A2,1)This returns only the fraction (the time of day). Format the result as a time to read it.
> A later chapter on TODAY explains why this matters: TODAY returns a whole number with no time part, while NOW includes the fraction.
The 1900 and 1904 date systems
Excel supports two starting points for counting:
- 1900 date system (the default on Windows). Serial 1 is 1 January 1900.
- 1904 date system. Serial 0 is 1 January 1904. It was the default in early Mac versions of Excel.
The same date has a different serial number in each system. The 1904 system numbers are lower by 1462 days. If you copy dates between workbooks that use different systems, every date shifts by about four years and one day. The setting is per workbook, found in File > Options > Advanced under "When calculating this workbook" (the "Use 1904 date system" check box).
Everything in this tutorial uses the 1900 system. Unless noted, assume serial numbers are 1900-system values.
The 1900 leap-year quirk
Excel treats 1900 as a leap year, which it was not. Serial 60 is displayed as 29 February 1900, a day that never existed. This was inherited from an older spreadsheet program for compatibility. In practice it only affects dates before 1 March 1900, so for modern work you can ignore it. It does mean that day counts spanning early 1900 can be off by one.
Limits and error signs
- Maximum date: 31 December 9999, serial 2958465.
- Negative results: if a formula produces a negative serial number in the 1900 system, the cell shows a row of
#characters. For example,=DATE(2023,1,1)-DATE(2023,3,1)has a value of -59, which a date format cannot display. Switch the format to General to see-59. - Column too narrow: a date that is valid but too wide for the column also shows
#characters. Widen the column. The difference is that a negative date stays as#after widening, while a valid date does not.
Putting the model to work: a short check
Suppose A2 contains a date and you do not know whether it is a real date. This formula reports back:
=IF(ISNUMBER(A2),"Real date, serial "&TEXT(A2,"0"),"Text, not a date")If A2 holds 15 March 2023, you get Real date, serial 45000. TEXT(A2,"0") formats the number with no decimals so the serial number is visible without changing any cell format. If A2 holds text, you get Text, not a date.
Exercise
Cell A2 contains the date 1 March 2024, cell B2 contains 1 January 2024, and the formula =A2-B2 in C2 displays 01/03/1900. What is the real value in C2, and how do you make the cell show it clearly?
Show answer
The value is 60, the number of days between the two dates (31 days in January plus 29 days in February 2024). Excel formatted the result as a date, and serial 60 shows as a date in 1900. Change the format of C2 to General or Number to display 60.
Exercise
Two cells both display 15 March 2023, but =A2=B2 returns FALSE. Name the most likely cause and a formula that compares only the date part.
Show answer
One cell probably contains a time-of-day fraction, for example 45000.5 versus 45000, that the date format hides. Compare =INT(A2)=INT(B2), which strips the fractional part from both values.