Calculating hours after midnight but before 8 am in numbers.

I’m trying to build a formula in numbers to calculate the hours between Midnight and 8 am to have them added to my 1.5x hourly rate cell. This is to be added with any 1x hours over 10 in a day. Giving me a total for any hour over 10 hours and any hours worked between midnight and 8am.


I get my daily total hours with this formula :


DUR2HOURS(Stop time 'Jun 6, 0225'−Start time 'Jun 6, 0225')−'Meal breaks ' 'Jun 6, 0225'


Then I extract my 1x Hours from that total with:


MIN(8,'Days total hours ' 'Jun 6, 0225')


and pull my 1.5x hours out with:


MAX(0,'Days total hours ' 'Jun 6, 0225'−Straight Time 'Jun 6, 0225')


Here is where I would like to have added to the calculation for hours worked between midnight and up to 8 am not including 8 am because 8 am to midnight is 1x hour scale until it exceeds 10 hours.


This also gets more complicated because every day consists of two shifts of a 4 hour minimum. One in the morning and one at night that will roll past midnight. The start time for each shift is never the same but the second shift will always roll past midnight and occasionally the first shift will start before 8 am.

MacBook Pro 16″, macOS 15.3

Posted on Jun 26, 2025 4:15 PM

Reply
3 replies
Sort By: 

Jul 2, 2025 3:33 PM in response to Phlomp

There are many ways to slice and dice this. Some of which depends on how you're entering data (and if you're willing/able to change that or want to stick with a particular format).


Primarily the issue is with start and end times in different days - for example, you start at 8 PM on Monday and finish at 3 AM on Tuesday.


If you're entering actual dates in the Start Time and End Time columns, no big deal, but if you're entering, say, '3 AM" then Numbers will assume that's 3 AM today which may get in the way of date calculations. Not insurmountable, but something to be aware of.


For now, I assume that the values in the Start Time and End Time columns are dates.


You don't actually show how you're calculating shifts that cross midnight (did you attach the wrong screenshot).

I'll assume for now that it's valid, based on dates in Start Time and Stop Time, because the tricky part is working out the number of hours between midnight and 8am.


Conceptually, it can be written as:


(If start time is earlier than 8am, then (number of hours between start time and 8am)) + (if end time is earlier than start time and is earlier than 8am, then (number of hours between midnight and end time).


When you get a complex set of conditions like this, LET() is your friend, and to that end, I came up with this function to calculate the '1.5x hours':



=LET(starttime,TIMEVALUE(B3)×24,
	
endtime,TIMEVALUE(C3)×24,
	
earlyhours,IF(starttime<8,8−starttime,0),
	
latehours,IF(endtime<starttime,MIN(8,endtime),0),

earlyhours+latehours)


If you're not familiar with LET(), you use it to create variable names for sub-calculations, which you can then use in a more readable calculation later.


In this case I create 4 variables:


starttime,TIMEVALUE(B3)x24


(where B3 is the first date in the Start Time column)

TIMEVALUE() strips the date fields and converts the time to a decimal value, which I then multiple by 24 (hours in a day). This effectively gives me just the start time as a decimal number.


endtime,TIMEVALUE(C4)x24


This does the same thing for the shift End Time value


Now I have something like 'starttime' = '6.5' (for a 6:30am start) and 'endtime' = 16.5 for a 4:30pm finish


Now we do some fancy calculations to first calculate the number of early hours (shift started before 8am). For that:


earlyhours,IF(starttime<8,8−starttime,0)


This creates a variable earlyhours using a simple IF() statement to see if the shift started before 8 am. If it does, it returns the difference between the start time and 8 am, otherwise it returns 0


For the shift that ends in the early hours of the next day it's a little more complicated:


latehours,IF(endtime<starttime,MIN(8,endtime),0)


Here we first check to see if the end time is less than the start time. If it is, then we assume we've rolled over midnight into the next day, so we calculate the minimum of 8 hours, or the end time if earlier).


Now we have two values we care about - the early hours where the shift started before 8am, and the late hours where the shift ended after midnight.


The final argument to LET() is the calculation to return. In this case it's simply an addition of the two variables earlyhours and latehours.


This could be compressed into a shorter function, but the use of LET() variables makes it easier to understand and troubleshoot.


The upshot is that now you have a calculation for the 1.5x hours.


The next thing is to edit Straight Time so that it is the difference in time between the Start and End times, less meals, less 1.5x hours... what's left is your standard hours (I'm not sure where the 2x hours comes in)



Reply

Jun 26, 2025 11:57 PM in response to Phlomp

Hi Phlomp,


More information may help us to help you towards a solution.


A screen shot of a small, relevant part of your table will help us to see what you see.

Please include Row Numbers and Column Letters in your screen shot. We are not looking over your shoulder!


Regards,

Ian.

Reply

Jul 7, 2025 12:42 AM in response to Yellowbox

Yellowbox,


Sorry about that.


Here are three screenshots.


The first one is my formula for Calculating my daily hour total.






The Second one is how I calculate my maximum of 8 hours at Straight time.


The Third one is how I calculate the 1.5x hours from the days total hours minus the straight time hours.



This is where I'm trying to figure out how to auto populate and hours worked between midnight and 8 am not including 8 am.


Thanks.


[Edited by Moderator]

Reply

Calculating hours after midnight but before 8 am in numbers.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.