Sub topic 2
Formats change the display, not the value
This chapter assumes you can enter values and formulas, use relative and absolute references, and apply number formats from the Format menu. The previous chapter showed that Sheets stores every date and time as a number. This chapter explains how that number gets turned into the text you see in the cell. It also shows why mixing up the two causes many date bugs.
Two layers in every cell
Every cell holding a date has two separate parts:
- The stored value, which is a number. For 28 November 2026 it is 46354, the count of days since the sheet's day 0 (30 December 1899).
- The number format, which is a rule that decides how that number appears on screen.
Changing the format never changes the stored value. Formulas, comparisons, sorting and charts all read the stored value. They never read the text you see.
The same stored value can look very different:
| Stored value | Format | Displayed as |
|---|---|---|
| 46354 | Date (en-US locale) | 11/28/2026 |
| 46354 | Custom `yyyy-mm-dd` | 2026-11-28 |
| 46354 | Custom `dddd, mmmm d, yyyy` | Saturday, November 28, 2026 |
| 46354 | Number | 46,354.00 |
| 46354.75 | Custom `yyyy-mm-dd hh:mm` | 2026-11-28 18:00 |
| 0.75 | Time | 6:00:00 PM |
The last row shows that a time of day is only a fraction of a day. A value of 0.75 is three quarters of the way through a day, which is 18:00. A date-time stores both parts: the whole number is the date and the fraction is the time.
Seeing the real value
When a cell shows a date, you can look at the stored number in three ways.
- Select the cell and choose Format > Number > Number. The display changes to the serial number. Use Edit > Undo or choose Format > Number > Automatic afterwards. Because this changes the format, you may prefer one of the next two methods.
- Put a formula in a spare cell that returns the number:
=N(A2)- Test whether the cell holds a number at all:
=ISNUMBER(A2)ISNUMBER returns TRUE for a real date or time and FALSE for text that only looks like one. You will use this check often when diagnosing problems.
Alignment is a quick visual hint. Numbers, including real dates, align to the right by default. Text aligns to the left. A "date" hugging the left edge of its cell is probably text.
Custom date and time formats
Choose Format > Number > Custom date and time to build a pattern from tokens. The most useful tokens are:
| Token | Meaning | Example for 2026-11-28 18:05:09 |
|---|---|---|
| `yyyy` | Four-digit year | 2026 |
| `yy` | Two-digit year | 26 |
| `mmmm` | Full month name | November |
| `mmm` | Short month name | Nov |
| `mm` | Month with leading zero | 11 |
| `m` | Month without leading zero | 11 |
| `dddd` | Full weekday name | Saturday |
| `ddd` | Short weekday name | Sat |
| `dd` | Day with leading zero | 28 |
| `d` | Day without leading zero | 28 |
| `hh` | Hour with leading zero | 18, or 06 with AM/PM |
| `mm` | Minutes, when next to hours or seconds | 05 |
| `ss` | Seconds with leading zero | 09 |
| `AM/PM` | Switches hours to 12-hour clock | PM |
The letter m is ambiguous because it means both month and minute. Sheets decides by position. When mm sits right after an hour token or right before a seconds token, it means minutes. Otherwise it means month. So hh:mm:ss reads as hours, minutes and seconds, while yyyy-mm-dd reads as year, month and day.
You can also type characters other than tokens, such as dashes, slashes, spaces and commas. The format yyyy-mm-dd and the format d mmm yyyy both work on the same stored number. They only differ in presentation.
What a format does and does not do
A format is not a conversion. It cannot repair text, and it cannot change precision. Three common surprises follow from that.
Text stays text
If a cell holds the text "2026-11-28", choosing a date format does nothing. The cell contents are not a number, so there is nothing to format. The fix is a conversion with a function such as DATEVALUE, covered in a later chapter. Formatting cannot do that job.
Display rounding hides precision
A time of 11:59:59.6 shown with the format hh:mm:ss appears as 12:00:00 because the display is rounded. The stored fraction is still slightly below 0.5. A date-time that shows only a date hides its time fraction in the same way. This leads to the classic mismatch:
=A2 = B2If A2 holds 2026-11-28 (value 46354) and B2 holds 2026-11-28 14:30 (value 46354.6042), both can be formatted as yyyy-mm-dd and look identical. The formula still returns FALSE, because the stored numbers differ. To compare only the date part, drop the fraction with INT:
=INT(A2) = INT(B2)INT rounds down to the whole number, which removes the time of day.
Results inherit formats from their inputs
When a formula's result is a date or time, Sheets often applies a matching format automatically. Adding a number to a date gives a date-formatted result:
=A2 + 7If A2 is a date, the result also displays as a date. Subtracting two dates gives a count of days, but the automatic format can be a date or duration pattern instead of a plain number:
=B2 - A2If this shows something like 12/30/1899 or 0:00:00 when you expected 9, the value is probably correct and only the display is wrong. Select the cell and choose Format > Number > Automatic or Number. The next chapters build on this habit of checking the format before doubting the formula.
Formats versus the TEXT function
Both approaches can display 2026-11-28, but they behave differently:
| Row | Cell format | `TEXT` function |
|---|---|---|
| Result type | Still a number | Text |
| Works in later calculations | Yes | No, unless converted back |
| Alignment by default | Right | Left |
| `ISNUMBER` returns | TRUE | FALSE |
| Best for | Normal date columns | Labels and joined strings |
This is the TEXT formula from the plan:
=TEXT(A2, "yyyy-mm-dd")Use TEXT when you need a date inside a longer string, such as ="Due " & TEXT(A2, "d mmm"). Use a cell format for any column you plan to sort, filter, subtract or chart. Sorting a column of TEXT results sorts alphabetically. With the pattern dd/mm/yyyy that puts 01/12/2025 before 02/01/2025, which is the wrong date order.
A short worked example
Set up this small test to see all of the above at once. Enter these in a new sheet:
A2: =DATE(2026, 11, 28)
B2: =A2 + 0.5
C2: =TEXT(A2, "yyyy-mm-dd")
D2: =ISNUMBER(C2)
E2: =INT(B2) = A2Then format A2 and B2 with Custom date and time yyyy-mm-dd. Expect these results:
- A2 and B2 look identical, but B2 holds 46354.5 and A2 holds 46354.
=A2 = B2would return FALSE, even though both display 2026-11-28.- C2 is text, left-aligned, and D2 returns FALSE.
- E2 returns TRUE, because
INTremoves the half day.
Now change B2's format to yyyy-mm-dd hh:mm. It becomes 2026-11-28 12:00 and nothing else changes.
Recap of habits
- Treat the display as a view of the number underneath.
- Check suspicious cells with
ISNUMBERorNbefore changing formulas. - Fix wrong-looking results by changing the format, not the formula.
- Compare dates with
INTwhen time fractions may be present. - Reserve
TEXTfor labels.
Exercise
Cell A2 shows 2026-11-28 and cell B2 shows 2026-11-28, both formatted yyyy-mm-dd. The formula =A2=B2 returns FALSE. Name a likely cause, and give two checks or formulas that confirm and fix it.
Show answer
One cell most likely holds a time fraction that the format hides, for example 46354.5 versus 46354. Alternatively, one cell may hold text that only looks like a date. To confirm, change the format of both cells to Number, or use =N(A2) and =N(B2), and check =ISNUMBER(A2) and =ISNUMBER(B2). If the fractions differ, compare with =INT(A2)=INT(B2). If one cell is text, convert it to a real date, for example with DATEVALUE.
Exercise
You format a cell holding the value 0.25 with the pattern hh:mm. What does it display, and what does the cell still contain afterwards?
Show answer
It displays 06:00, because 0.25 is a quarter of a day. The cell still contains the number 0.25. Only the display rule was applied.