I am looking to calculate hours worked in a month based on a salaried employee's hire date and termination date (if it exists), based on a salaried worker's hours of 2,080 hours in a year. I have been basing per month on the Excel formula "NETWORKINGDAYS" and multiplying by 8 (hours per day) to turn the days into hours. I have done this in a manual fashion in the past - filtering to see if someone was employed during the full month - meaning they did not have a hire date or a termination date during a given month. I would then go back and use the NETWORKINGDAYS formula to handle the employee records that did have a hire or termination date within the given month.
I am looking for a way to automate this calculation. Criteria I need to handle the below, using January 2023 as an example. January 2023 has 176 salaried working hours in it (based on US calendar):
I am trying to make this extendable - right now I am doing this month by month, one month at a time, but I want to be able to calculate an employee's monthly hours for a whole year using one formula.
Formula examples from the attached image:
Test Employee, February 2023 hours: =NETWORKDAYS("2/1/2023",E3)*8
Test 2 Employee, February 2023 hours: =NETWORKDAYS(D4,EOMONTH("2/1/2023",0))*8
Test 3 Employee, January 2023 hours: =NETWORKDAYS("1/1/2023",EOMONTH("1/1/2023",0))*8
I would create a helper row above the labels with an actual date like 1/1/23, you can hide this row after but it will save you the trouble of calculating. I'll assume the table we're looking at goes from A1:G4, A1:G1 being the headers. If you move this down and put the dates above those headers this is the formula I'd write into E3:G5. (specifically to E3), referencing the dates above the header in now the new E1:G1...
First this checks if the start date is after the end of that columns month, if so 0. Then it checks that if the term date is not blank and earlier than that month also 0. With those out of the way we start the networkdays but within the start date, we check if it's the same month & year as the date. If it is, we want the greater of the 2, start date, otherwise the date. Similarly for the end date if it's the same month/year as the term date then use the term date otherwise use the eomonth of that date.
Added note, with NETWORKDAYS if you need to you can add a list of the holidays you want excluded as the final condition in order to have those considered as well.
=IF(OR( $C3>EOMONTH(E$1,0),AND(ISNUMBER($D3), $D3<E$1)),0, NETWORKDAYS( IF(AND(MONTH($C3)=MONTH(E$1), YEAR(E$1)=YEAR($C3)),$C3,E$1), IF(AND(MONTH($D3)=MONTH(E$1), YEAR(E$1)=YEAR($D3)),$D3,EOMONTH(E$1,0))))*8