Sub topic 2
Format versus value: seeing the serial number
This chapter assumes you can enter formulas, refer to cells such as A2, and apply a number format from the Home tab or the Format Cells dialog. The previous chapter introduced the idea that a date is a count of days. Here you learn how to tell what a cell stores from what it shows.
Two layers in every cell
A cell holds a value and a number format. The value is what Excel calculates with. The number format is a display rule that turns the value into text on screen.
For a date, the value is a serial number. The format decides whether you see 45000, 15-Mar-2023, or Wednesday, March 15, 2023. Changing the format never changes the value, so every formula that refers to the cell behaves the same.
Seeing the serial number
Enter this formula in a cell:
=DATE(2023,3,15)Excel usually formats the result as a date. To see the serial number, select the cell and switch it to General. You can use Home > Number Format > General, or press Ctrl+Shift+~ on Windows. The cell now shows 45000.
To switch back, choose a date format from the same list or press Ctrl+Shift+# on Windows. The value stays 45000 throughout.
| Number format | Display for 45000 |
|---|---|
| General | 45000 |
| yyyy-mm-dd | 2023-03-15 |
| d-mmm-yyyy | 15-Mar-2023 |
| dddd, mmmm d, yyyy | Wednesday, March 15, 2023 |
Format codes such as d, mmm, and yyyy are custom number formats. You enter them in Format Cells > Custom. Some localized versions of Excel use different letters for these codes.
Why this matters
Because formatting only changes the display, you can show the same date in several ways without changing any calculation. The reverse also holds. A number that looks like a date might be plain text, and a date might look like a number. Two quick checks tell you which case you have:
- Temporarily switch the cell to General. A real date turns into a number such as 45000. Text stays unchanged.
- Look at the alignment. Real dates and numbers right-align by default, and text left-aligns.
Common errors
- A date shows as a five-digit number. The cell has General format, or a formula result did not receive a date format. Apply a date format. Excel sometimes picks a format for a formula result on its own and sometimes does not.
- A cell shows
#####. The column is too narrow for the formatted text. Widen the column. A negative date value also displays as#####, because the 1900 date system has no dates before serial 1. - A number shows as a date. A cell holding
45000can show15-Mar-2023if someone applied a date format to it. This is correct behavior. It is not a calculation error. - A function returns text, not a date.
TEXT(A2,"yyyy-mm-dd")produces text that looks like a date but is no longer a serial number. Use it only for display, such as inside a label. Keep the original date cell for calculations.
=TEXT(A2,"yyyy-mm-dd")Exercise
Cell B2 contains the formula =DATE(2023,3,15) and is formatted as d-mmm-yyyy. You change B2 to General format. What does it show, and does the formula in C2, =B2+1, change its result?
Show answer
B2 shows 45000, the serial number for 15 March 2023. C2 does not change. It returns 45001 in both cases, because formatting only affects how B2 is displayed and not the value that C2 uses. C2 displays as a date or a number depending on its own format.
Exercise
A cell shows 2023-03-15 and is left-aligned. Switching it to General leaves it as 2023-03-15. Is it a real date? How would you convert it?
Show answer
No. It is text, because a real date would change to a serial number such as 45000 under General. You can convert it by re-entering it as a date. You can also use =DATEVALUE(A2) and format the result as a date. The Text dates and common errors chapter covers this in more detail.