Sub topic 5
Time of day as a fraction of a day
This chapter assumes you can enter formulas, use cell references such as A2, and apply a number format to a cell. It also assumes you have read the earlier chapters in this tutorial. In them, a date is a whole number that counts days, and a cell's format controls only how that number is displayed.
Here you will see how Excel stores the time of day, how to build and take apart date-times, and which errors to expect when time values cross midnight or run past 24 hours.
The model: a day is 1, so a part of a day is a fraction
Excel counts one full day as 1. The whole-number part of a serial number identifies the date. Anything after the decimal point is the time of day, measured as the fraction of that day that has passed since midnight.
- 45000 is 15 March 2023 at 00:00 (midnight at the start of the day).
- 45000.5 is 15 March 2023 at 12:00, half a day later.
- 45000.75 is 15 March 2023 at 18:00, three quarters of the way through the day.
A cell that holds only a time, such as 6:00, holds a value between 0 and 1. Excel stores 6:00 as 0.25, and it has no separate time data type.
Converting between units and fractions
A day has 24 hours, 1,440 minutes, and 86,400 seconds. Each unit of time is therefore a fixed fraction of a day.
| Unit | Fraction of a day | Approximate value |
|---|---|---|
| 1 hour | 1/24 | 0.0416667 |
| 1 minute | 1/1440 | 0.000694444 |
| 1 second | 1/86400 | 0.0000115741 |
| 6 hours | 6/24 | 0.25 |
| 12 hours | 12/24 | 0.5 |
To convert a fraction of a day into another unit, multiply by the number of units in a day:
- Hours: multiply by 24.
- Minutes: multiply by 1440.
- Seconds: multiply by 86400.
To convert the other way, divide by the same number.
Seeing the fraction
You can use the same technique as for dates to inspect a time value. Type a time into a cell, then change the cell's format from a time format to General. The cell then shows the underlying number.
If A2 holds 8:30 AM and you switch it to General, it shows 0.354166667. That is 8.5 hours divided by 24.
You can also build the fraction with a formula:
=8.5/24With a time format applied, this displays 8:30 AM. With General, it displays 0.354166667.
Building times with TIME
The TIME function takes hours, minutes, and seconds and returns the matching fraction of a day. It plays the same role for times that DATE plays for dates.
=TIME(8,30,0)This returns 0.354166667, which a time format displays as 8:30 AM.
TIME does not accept values that fall outside its limits. If the hour is above 23, it wraps around within a day. For example, =TIME(25,0,0) returns the same value as =TIME(1,0,0), which is 0.0416667. Use this wrapping behavior with care, because it can hide a mistake. If you need more than 24 hours, add the fraction yourself, as in =30/24.
Combining a date and a time
Because a date is a whole number and a time is a fraction, you can add them to get a date-time:
=DATE(2024,3,1)+TIME(14,30,0)DATE(2024,3,1) is serial number 45352. TIME(14,30,0) is 0.604166667. The result is 45352.604166667. With a format such as yyyy-mm-dd hh:mm, it displays as 2024-03-01 14:30.
You can also type a date and time together into a cell, such as 2024-03-01 14:30. Excel recognizes that as a date-time and stores it the same way.
Taking a date-time apart
Several functions extract the pieces of a time value. Assume A2 holds a date-time, such as the 45352.604166667 above.
| Formula | Returns | Meaning |
|---|---|---|
| `=INT(A2)` | 45352 | The date part, with time removed |
| `=MOD(A2,1)` | 0.604166667 | The time part, as a fraction |
| `=HOUR(A2)` | 14 | The hour, from 0 to 23 |
| `=MINUTE(A2)` | 30 | The minute, from 0 to 59 |
| `=SECOND(A2)` | 0 | The second, from 0 to 59 |
INT removes the fraction, and MOD with a divisor of 1 keeps only the fraction. These two are the most useful for splitting a date-time into separate date and time columns.
Date-times and date comparisons
A date-time is not equal to the plain date of the same day. The two differ by the time fraction.
Suppose A2 holds 2024-03-01 14:30, which is 45352.604166667. Then:
=A2=DATE(2024,3,1)returns FALSE, because 45352.604166667 is not equal to 45352. If you want to ask whether A2 falls on 1 March 2024, remove the time first:
=INT(A2)=DATE(2024,3,1)This returns TRUE.
This matters most for counting rows or filtering by date. A lookup or a COUNTIF that matches on a whole date can miss rows that carry a time. When a column came from a system that records timestamps, add a helper column with =INT(A2) and use that column for date matching.
The same issue affects day counts. =TODAY()-A2 returns a whole number only if A2 has no time part. TODAY returns the current date with no time. If A2 is a date-time such as 2024-03-01 14:30, the difference includes a fraction, because TODAY sits at midnight and A2 does not. Wrap the formula in INT if you want whole days.
Subtracting times and measuring durations
Subtracting two date-times returns the elapsed time in days, as a fraction. Suppose A2 holds a start of 2024-03-01 09:00 and B2 holds an end of 2024-03-01 14:30.
=B2-A2This returns 0.229166667, which is 5.5 hours expressed as a fraction of a day. To get hours, multiply by 24:
=(B2-A2)*24This returns 5.5. Multiply by 1440 for minutes (330) or by 86400 for seconds (19,800).
Showing durations over 24 hours
If you apply a time format such as h:mm to a duration, Excel displays only the time-of-day portion. A duration of 1.5 days, formatted as h:mm, shows 12:00, because the whole day is dropped from the display. The stored value is still 1.5.
To show total hours, put the hour code in square brackets:
[h]:mmshows 1.5 days as 36:00.[m]shows total minutes.[s]shows total seconds.
The brackets tell Excel to keep counting past the normal limit instead of wrapping at 24 hours, 60 minutes, or 60 seconds.
Crossing midnight
A shift that starts at 22:00 and ends at 06:00 gives a wrong answer with plain subtraction. If A2 holds 22:00 (0.916666667) and B2 holds 06:00 (0.25), then =B2-A2 returns -0.666666667. Negative time values cannot be displayed in the default 1900 date system. The cell shows a row of # characters instead.
The fix uses MOD, which keeps the result between 0 and 1:
=MOD(B2-A2,1)This returns 0.333333333, which is 8 hours. Multiply by 24 to get the number:
=MOD(B2-A2,1)*24This returns 8. The formula assumes the shift is shorter than 24 hours. If the start and end both carry dates, plain subtraction already works across midnight, and you do not need MOD.
Rounding and equality
Fractions of a day are stored as binary floating-point numbers, and many of them cannot be represented exactly. A time you built by adding or multiplying fractions might differ from the same time entered directly by a tiny amount, far below what the display shows. Comparing two such values with = can then return FALSE even though both display as the same time.
To compare computed times safely, round both to a unit you care about. For example, to compare to the second:
=ROUND(A2*86400,0)=ROUND(B2*86400,0)This converts each value to seconds, rounds to a whole second, and compares the results. Use the same approach when you group or look up values by time.
Where this leads
The model in this chapter gives you three practical rules:
- Whole numbers are dates and fractions are times, so INT and MOD separate them.
- Multiply a day fraction by 24, 1440, or 86400 to get hours, minutes, or seconds.
- Use a bracketed format such as
[h]:mmfor durations, and MOD for spans that cross midnight.
The next chapters build on this. They cover the 1900 and 1904 date systems, which change how negative times display and how the serial numbers are offset, and the TODAY function, which returns a date with no time part.
Exercise
A2 holds the date-time 2024-03-01 18:00. What serial number does it contain, and what does =MOD(A2,1) return?
Show answer
DATE(2024,3,1) is 45352, and 18:00 is 18/24 = 0.75, so A2 holds 45352.75. =MOD(A2,1) returns 0.75, the time-of-day fraction.
Exercise
A2 holds a start time of 21:30 and B2 holds an end time of 05:15 on the next morning. Write a formula that returns the number of hours worked, and give the result.
Show answer
=MOD(B2-A2,1)*24. The end is 5.25/24 = 0.21875 and the start is 21.5/24 = 0.895833, so B2-A2 is negative. MOD brings it to 0.322917, and multiplying by 24 gives 7.75 hours.
Exercise
A cell holds the value 2.25 and is formatted as h:mm. It displays 6:00. How can you make it show the total duration in hours, and what would it show?
Show answer
Change the format to [h]:mm. The value is 2.25 days, which is 54 hours, so it would show 54:00.