When we want to count the num­ber of work­ing hours in Excel, we have z prob­lem with night shifts. Let’ start with a human approach and day shift. 

Work­ing hours and wages. Night shifts | Excel Tips #28

In a day shift, the end time is larg­er that the start time, so we can just sub­tract one num­ber from anoth­er (Fig. 1). 

=(B2-A2)

Subtracting one number from another
Fig. 1 Sub­tract­ing one num­ber from another

After enter­ing and copy­ing down, we can see we have prop­er results for day shifts. In night shifts, when the end time is small­er that the start time, it does’t show us any time, only hash­tags. It hap­pened so because Excel refused to show any neg­a­tive dates or time. Even if Excel showed us neg­a­tive results, they would be wrong (Fig. 2). 

No negative time
Fig. 2 No neg­a­tive time

First, we have to remem­ber that Excel stores time as num­bers, i.e. the part of the day that has passed. When we look at the first hour, which is 8 am, it means that one-third of the day has passed. When we go to the Time bar, and press Gen­er­al, we can see that the time will be giv­en in dec­i­mal num­bers (Fig. 3), (Fig. 4). 

 General Time
Fig. 3 Gen­er­al Time 
Time in decimal numbers
Fig. 4 Time in dec­i­mal numbers

When we want to con­vert Excel time into human time, we have to mul­ti­ply it by 24 (Fig. 5). 

=(B2-A2)*24

Excel time into human time
Fig. 5 Excel time into human time

Now, we can see that the we can eas­i­ly read the val­ues. Remem­ber to have the Gen­er­al option select­ed. There are neg­a­tive val­ues for the night shift. What’s more, they are wrong, as there are only 8 hours from 8 pm to 4 am in row num­ber 3, not 16. 

Negative and wrong results
Fig. 6 Neg­a­tive and wrong results

It means that this human approach won’t work in Excel, so let’ delete the results. What can work here is a func­tion called MOD, which is also quite short. In the MOD func­tion, we also use the human approach, which means that from the end time we sub­tract the start time. How­ev­er, the MOD func­tion needs a divi­sor, i.e. 1, which means that it is one whole day (Fig. 7)

=MOD(B2-A2,1)

Divisor
Fig. 7 Divisor

Now, we can see that our results in day and night shifts are cor­rect. We can final­ly cal­cu­late the wages by mul­ti­ply­ing the num­ber of work­ing hours by the hourly wage (Fig. 8). 

=C2*$F$2

Calculating wages
Fig. 8 Cal­cu­lat­ing wages

As we can see the results are wrong again. Let’s have a look at row num­ber two. There are 8 hours, but Excel does­n’t mul­ti­ply 8 hours times 40$, but one third of a day times 40$, which gives us around $13 (Fig. 9).

Wrong results
Fig. 9 Wrong results

We want to have prop­er wages, so we need to mul­ti­ply it by 24 hours (Fig. 10).

=C2*$F$2*24

Multiplying by 24
Fig. 10 Mul­ti­ply­ing by 24

Now, we have prop­er wages (Fig. 11). 

Proper wages
Fig. 11 Prop­er wages

If you don’t need pre­ci­sion big­ger than 15 min­utes, just use num­bers instead of Excel time. I’m advis­ing it to you from my own experience. 

https://www.youtube.com/watch?v=UTYF245AGRo