Santa's Elf Time Card, Part 1: The Night Shift
The elves work right through midnight on Christmas Eve. Your formulas should too.
Every December, Santa's workshop runs around the clock. Juniper Snowberry, one of the best toy builders at the North Pole, clocks in at 8:00 PM on Christmas Eve and clocks out at 4:00 AM on Christmas morning. When the payroll elf types those times into an Excel time card, the hours column fills with ##### instead of 8 hours.
The same thing happens in hospitals, factories, and anywhere else people work a night shift. A simple subtraction of start time from end time works fine unless the shift crosses midnight. Then the weekly total on the Excel time card gets strange too: a 61-hour week shows up as 13:30. Here's how to build a time card that gets both right.
Want to follow along? Download the free December practice workbook and open the Time Card sheet. The yellow cells are yours to fill in.
1. Enter Times Excel Understands
Excel stores a time as a fraction of a day. Noon is 0.5 (half a day), and 6:00 AM is 0.25. That's what lets an Excel time card subtract one time from another. But it only works if Excel recognizes what you typed as a time.
- Type the hour, a colon, and the minutes: 6:30.
- Add a space and then AM or PM: 6:30 PM. (Or use the 24-hour clock and type 18:30.)
- Press Enter and check the alignment. A time Excel understands lines up on the right side of the cell. If it lines up on the left, Excel saw it as text, so retype it.
Outcome: Every time on the card is a real time value that formulas can add and subtract.
2. Subtract Clock In from Clock Out
Say it in English first: hours worked equals the time I left minus the time I arrived. In the practice workbook, on the Time Card sheet, Clock In is in column C and Clock Out is in column D, so the simple Excel time card formula would be =D10-C10. That works for every daytime shift. Now try it on Christmas Eve:
- Click cell E15 (Christmas Eve).
- Type =D15-C15 and press Enter.
- Instead of 8 hours, Excel fills the cell with #####.
Outcome: You've found the problem every night-shift time card runs into, and you know exactly which row needs a better formula.
3. Fix the Night Shift: Add a Day When Needed
On Christmas Eve, 4:00 AM minus 8:00 PM is a negative number. Excel can't show a negative time, so it fills the cell with #####. Making the column wider won't help.
Say it in English: subtract Clock In from Clock Out. If the elf clocked out earlier in the day than they clocked in, the shift crossed midnight, so add one day. Since Excel counts one whole day as 1, the translation is short:
=D10-C10+IF(D10 Now read the formula back in English, one piece at a time: Use this formula on every row of the Excel time card, not just the night shifts. That way it keeps working no matter which shift an elf picks up next week. In other workbooks, you may also see =MOD(D10-C10,1) used for the same job. MOD wraps a negative time around the clock and gives the same answer. The IF version is easier to read, because it says exactly what it's doing. Outcome: One formula handles day shifts and overnight shifts alike, so the time card never breaks at midnight. Now add up the week on the Excel time card in E16: =SUM(E10:E15) Excel shows 13:30. Juniper will not be happy. The regular h:mm format works like a clock: after 24 hours it starts over, just as a clock goes from 11:59 back to 12:00. Excel has the right total stored in the cell. It just isn't displaying it. The total now reads 61:30. The square brackets around the h tell Excel to keep counting hours instead of starting over at 24. (More about this shortcut in Ctrl 1: One Shortcut, Four Jobs.) Outcome: The weekly total shows every hour worked, which is the number payroll actually needs. Before you hand the time card to anyone, take ten seconds to make sure the answers make sense: With one elf, your eyes can do the checking. With a whole workshop, you need Excel to check it twice for you. That's what Part 2: Checking It Twice is all about. Outcome: Mistakes get caught before they reach payroll, not after. Tip: If you ever see a time of day such as 9:30 AM where you expected 9:30 hours, press Ctrl 1, choose Custom, and type h:mm. For more examples, see Microsoft's Add or subtract time in Excel and the MOD function reference. An Excel time card only needs two fixes to be ready for any shift: adding a day for the hours that cross midnight, and using the [h]:mm number format for the totals that pass 24. Build them in once, and your Excel time card is ready for Christmas Eve and every night shift after it. 🎁 Ready for Part 2? The same practice workbook has a second sheet with a whole workshop of elves and three mistakes hiding in their time cards. Turn hours into pay and build a formula that finds the problems for you. Need a time card or payroll workbook built for your team? Reach out to us and let us know how we can help you.
Excel says
In English
=D10-C10 Clock Out minus Clock In +IF(D10 plus... is Clock Out earlier than Clock In? 1, If yes, the shift crossed midnight, so add one day 0) If no, add nothing, and the subtraction stands as it is
4. Total the Week, Then Fix the Total
5. Give the Excel Time Card a Quick Once-Over
Quick Reference
You want to
Use
Find hours worked on a daytime shift =D10-C10 Find hours worked on any shift, including overnight =D10-C10+IF(D10 Show hours and minutes for each shift Ctrl 1 > Custom > h:mm Show a total of more than 24 hours Ctrl 1 > Custom > [h]:mm Clocking Out