Sub topic 10
Dates and times as serial numbers
This chapter assumes you can enter data in cells, write a basic formula such as =A1+B1, and select ranges and use the Ribbon. It also assumes you know that a cell's stored value and its displayed format are separate things.
How Excel stores a date
Excel does not store a date as text or as a special date object. It stores a plain number called a serial number. The serial number counts days from a starting point. Under the default 1900 date system, serial number 1 is January 1, 1900, and every following day adds 1.
A number format then decides whether you see 45292 or 1/1/2024. The value in the cell is the same either way.
=DATE(2024,1,1)This formula returns 45292. If the cell has General format, Excel usually applies a date format to the result of DATE automatically. If you clear the format, you see the bare number.
| Serial number | Meaning under the 1900 system |
|---|---|
| 1 | January 1, 1900 |
| 45292 | January 1, 2024 |
| 46353 | November 27, 2026 |
| 2958465 | December 31, 9999, the latest date Excel accepts |
You can check this yourself. Type a date in A1, then select the cell and apply the General format with Ctrl+Shift+~. The cell shows the serial number.
How Excel stores a time
A time of day is stored as a fraction of one day. The fraction is added after the decimal point of the serial number.
| Time | Fraction of a day | Stored value |
|---|---|---|
| 00:00 (midnight) | 0 | 0 |
| 06:00 | 6/24 | 0.25 |
| 12:00 (noon) | 12/24 | 0.5 |
| 18:00 | 18/24 | 0.75 |
| 23:59:59 | 86399/86400 | 0.999988… |
A date and a time combine into one number. The integer part is the date and the fractional part is the time. So 45292.75 is January 1, 2024 at 6:00 PM.
Doing arithmetic with dates and times
Because dates are numbers, ordinary arithmetic works on them. Adding 1 moves forward one day. Subtracting two dates gives the number of days between them.
=A1+30This returns the date 30 days after the date in A1.
=B1-A1This returns the number of days from A1 to B1. Excel may format the result as a date, because it inherits formatting from the cells it refers to. If you see something like 1/14/1900, apply the General or Number format to the result cell.
To add hours, divide by 24. To add minutes, divide by 1440, which is 24 × 60.
=A1+3/24This adds three hours to the date and time in A1.
Splitting a date and time apart
When a cell holds both a date and a time, such as the result of NOW(), you can separate the two parts.
=INT(A1)This returns only the date, and the time becomes 0 (midnight).
=A1-INT(A1)This returns only the time, as a fraction between 0 and 1. Format the result with a time format such as h:mm AM/PM to read it.
MOD(A1,1) gives the same fractional result. The functions TODAY() and NOW() are volatile. They recalculate every time the workbook recalculates. TODAY() returns a whole-number date, and NOW() includes the time.
Creating serial numbers from text
Sometimes a date arrives as text, for example from a CSV file. The text looks like a date, but it is not a number, so arithmetic on it fails or gives wrong results. DATEVALUE converts date text into a serial number.
=DATEVALUE("2026-11-27")This returns 46353. Apply a date format to display it as a date. TIMEVALUE("18:00") does the same for times and returns 0.75. The text must match a date or time layout that your Excel installation recognizes. Chapter material on regional settings covers why a layout that works on one computer can fail on another.
To build a date from separate year, month, and day numbers, use DATE. It is more reliable than assembling text. DATE also rolls over out-of-range values, so =DATE(2024,13,1) returns January 1, 2025.
Two date systems
Excel supports two date systems.
- 1900 system: serial 1 is January 1, 1900. This is the default in Excel for Windows and in current Excel for Mac.
- 1904 system: serial 0 is January 1, 1904. Older Excel for Mac files used this system, and a workbook can still be set to use it.
The two systems differ by 1,462 days. If you copy dates between workbooks that use different systems, every date shifts by about four years and one day. You can check the setting in the workbook's advanced options under "Use 1904 date system".
Things that go wrong
Negative dates and ####
Excel's 1900 system has no dates before serial 1. A formula that gives a negative number, such as subtracting a later date from an earlier one, displays #### when the cell has a date format. The cell is not broken. The value is a negative number that a date format cannot show. Change the format to General to see the number. A very narrow column also causes ####, so widen it if the value is positive.
Time rounding
Times are stored as binary floating-point fractions, so tiny rounding errors can appear. A test such as =A1=B1 can return FALSE for two times that look identical. When you compare computed times, round them first.
=ROUND(A1,5)=ROUND(B1,5)Five decimal places is about one part in 100,000 of a day, or roughly one second.
Dates that are text
If a "date" is left-aligned and does not change when you reformat it, it is probably text. Left alignment is a hint, though not proof. ISNUMBER(A1) is the reliable test. It returns TRUE for real dates and FALSE for text.
=ISNUMBER(A1)Converting text to numbers and dates is covered in its own chapter.
Summary of the model
- A date is an integer serial number of days. A time is a fraction of a day. A date with a time is the sum of both.
- Number formats change only the display, so formatting a date as General reveals its serial number.
- Arithmetic works on dates directly. Divide by 24 for hours and by 1440 for minutes.
- Check the date system and watch for text dates, negative results, and floating-point comparisons.
Exercise
A cell contains 45293.75 and is formatted as General. What date and time does it represent under the 1900 date system, and what formula returns only the time portion?
Show answer
45293 is one day after 45292 (January 1, 2024), so the date is January 2, 2024. The fraction 0.75 is 18/24 of a day, so the time is 6:00 PM. The formula =A1-INT(A1) (or =MOD(A1,1)) returns 0.75, which you can format with a time format to display 6:00 PM.
Exercise
A formula =B1-A1 subtracts an earlier date in A1 from a later date in B1, but the result cell shows 1/14/1900 instead of 13. Why, and how do you fix it?
Show answer
Excel copied a date format to the result cell, and the value 13 is a serial number that displays as a date near the start of 1900 (January 13, 1900; the exact display depends on the number). The value is correct. Apply the General or Number format to the result cell so it shows the number of days.