## How to Calculate Total Work Days or Hours Exclude Weekends/Holidays in Excel

In our daily work we often need to count the total working-days or working-hours for employees then we can pay for them the salary in some cases. But we have to count the total exclude weekends or holidays as we don’t work on these days. So, we need to know how can we calculate the total work days or hours exclude these non-working days. Actually, excel functions are so strong that can be used directly to do calculation for some specific cases, this article will introduce you to calculate total work days/hours by NETWORKDAYS function, now let’s get started.

Before learning the formula, we need to prepare a simple table for demonstration. In above table, we can see that the normal working day is started from 9:00 (lower) to 18:00 (upper), total 9 hours, and we want to calculate the work days/hours (exclude weekends) between 3/2/2020 15:00 to 3/9/2020 18:00. Holidays is 3/5/2020. Please make sure the format is correct for your date and time. If you are not sure the format for your cells, you can enter Format Cells window to set them by date or time or custom. ## Part 1: Calculate Total Work Days Exclude Weekends

As we mentioned, we will use NETWORKDAYS function to count days. This function is easily to understand, it is used for returning the days between start date and end date, it automatically excludes the weekends.

=NETWORKDAYS(start_date,end_date,holidays)

Step 1: In C26, enter the formula =NETWORKDAYS(A26,B26). Step 2: Click Enter to get result. Step 3: As we set cell format as date and time, so we need to convert it to general for C26. Select C26, and click dropdown list in Number. Select General. Step 4: Verify that 6 is displayed properly. It is an approximate value for total work days, start time and end time are not included into consideration. Anyway, it already excludes the weekends as we expect. ## Part 2: Calculate Total Work Days Exclude Holidays

We just need to add holiday parameter into the formula. So, in C26, this time we enter =NETWORKDAYS(A26,B26,A34), then click Enter. Verify that this time 5 is displayed as total work days. Holiday is excluded. ## Part 3: Calculate Total Work Hours Exclude Weekends

If we pay for salary based on hours or we need to know an exactly working hours for an employee, we can use NETWORKDAYS function to calculate total work hours as well, but the formula is a little complex, and it also contains some other functions.

Step 1: In D26, enter the formula

=(NETWORKDAYS(A26,B26)-1)*(B31-B30)+IF(NETWORKDAYS(B26,B26),MEDIAN(MOD(B26,1),B31,B30),B31)-MEDIAN(NETWORKDAYS(A26,A26)*MOD(A26,1),B31,B30). You can see details below about formula. I marked parameters in blue.

=(NETWORKDAYS(Start Date Time,End Date Time)-1)*(Upper-Lower)+IF(NETWORKDAYS(End Date Time, End Date Time),MEDIAN(MOD(End Date Time,1),Upper,Lower),Upper)-MEDIAN(NETWORKDAYS(Start Date Time,Start Date Time)*MOD(Start Date Time,1),Upper,Lower)

Step 2: Click Enter to get the result. As currently the format is set as General when calculating total work days in Part 1. So, 2 is displayed in this field now. We need to convert it to proper format later. It also can be displayed as 1/2/1900 0:00 probably if you don’t change format during the whole process. Step 3: Select D26, right click to load menu, then select Format Cells to convert format for this cell. Step 4: Under Number tab, select Custom in Category list, then select [h]:mm:ss, click OK. You can also type your own format as well. Step 5: Verify that 48 hours is calculated properly. Notes:

If the start time and end time are both included between upper and lower period, you can use a simpler formula below:

=(NETWORKDAYS(Start Date Time,End Date Time)-1)*(Upper-Lower)+MOD(End Date Time,1)-MOD(Start Date Time,1)

In this case, enter below formula:

=(NETWORKDAYS(A26,B26)-1)*(B31-B30)+MOD(B26,1)-MOD(A26,1) ## Part 4: Calculate Total Work Hours Exclude Holidays

You can just use 48 to minus 9 hours (Upper-Lower). Or you can also use below format, just add holiday parameter into the first NETWORKDAYS function is ok.

=(NETWORKDAYS(A26,B26,A34)-1)*(B31-B30)+IF(NETWORKDAYS(B26,B26),MEDIAN(MOD(B26,1),B31,B30),B31)-MEDIAN(NETWORKDAYS(A26,A26)*MOD(A26,1),B31,B30) ### Related Functions

• Excel MEDIAN function
The Excel AVERAGE function returns the median of the given numbers. And the median is the number in the middle of a list of supplied numbers.The syntax of the MEDIAN function is as below:=MEDIAN (number1, [number2], …)….
• Excel IF function
The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])….
• Excel MOD function
he Excel MOD function returns the remainder of two numbers after division. So you can use the MOD function to get the remainder after a number is divided by a divisor in Excel. The syntax of the MOD function is as below:=MOD (number, divisor)….

## How to Calculate the Median in Different Cases in Excel

The median is the number in the middle of a range of data by order, half of the data in this range is larger than it, and half is smaller than it. Sometimes we want to calculate the median for a range of data. This article will introduce you the formula to calculate the median for a range in some different cases in excel.

## Calculate the Median for A Range Including Zero Number

See example below: Step 1: In any blank cell, enter the formula =MEDIAN(A1:B3). Step 2: Click Enter to get the result. Verify that zero number is included in calculating. ## Calculate the Median for A Range Excluding Zero Number

We still use above example to calculate the median, but this time zero numbers will be ignored in calculating.

Step 1: In any blank cell, enter the formula =MEDIAN(IF(A1:B3>0,A1:B3)). Step 2: Press ‘Ctrl + Shift + Enter’ to get the result. Verify that zero number is excluded in calculating. ## Calculate the Median for Multiple Ranges in Excel

See the table below: You can see that there are two ranges of data in two tables. So, if we want to calculate the median for the two ranges, you can follow below steps to calculate the median.

Step 1: In any blank cell, enter the formula =MEDIAN(A1:B3,A5:B7). If there are multiple ranges exist, we can use a comma to separate different ranges.

Step 2: Click Enter to get the result. ### Related Functions

• Excel MEDIAN function
The Excel AVERAGE function returns the median of the given numbers. And the median is the number in the middle of a list of supplied numbers.The syntax of the MEDIAN function is as below:=MEDIAN (number1, [number2], …)….
• Excel IF function
The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])….

## Excel MEDIAN Function

This post will guide you how to use the MEDIAN function with syntax and examples in Microsoft excel.

### Description

The Excel MEDIAN function returns the median of the given numbers. And the median is the number in the middle of a list of supplied numbers.  For example, if a list of supplied numbers are 3, 5, 6, 7, 8, the MEDIAN function will return the middle number in this list, it is number 6.

The MEDIAN function is a build-in function in Microsoft Excel and it is categorized as a Statistical Function.

The MEDIAN function is available in Excel 2016, Excel 2013, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000, Excel 2011 for Mac.

### Syntax

The syntax of the MEDIAN function is as below:

``= MEDIAN (number1, [number2], ...)``

Where the MEDIAN function arguments are:

• number1 – This is a required argument.  A number or array or cell reference that contain only numeric values.
• number2-This is an optional argument.  A number or array or reference that refers to numeric values. It can be up to 255 numeric values in Excel 2007 or later. And it only can be up to 30 number arguments in Excel 2003.

Note:

• If the total number of supplied number arguments is odd, the MEDIAN function will calculate the middle number in the list of numbers.
• If the total number of supplied number arguments is even, the MEDIAN function will calculate the average of the two numbers in the middle.
• Any arguments can either be numeric values or Defined names, arrays, or cell reference that contain only numeric values.
• If the list of number arguments contain logical values text, or empty cells, those values will be ignored.

### Excel MEDIAN Function Examples

The below examples will show you how to use Excel MEDIAN Function to get the middle number of a group of a supplied numbers.

Example 1:  to get the median of the 8 numbers in the range A1:A6. Because the list have 7 values, the fourth is the middle number, using the following formula:

``=MEDIAN (A1:A7)``

Example 2:  to get the median of the 8 numbers in the range A1:A8. Because the total number of supplied list is even, it will calculate the average the two numbers in the middle, using the following formula:

``=MEDIAN (A1:A8)``

### Related Functions

• Excel AVERAGE function
The Excel AVERAGE function returns the average of the numbers that you provided.The syntax of the AVERAGE function is as below:=AVERAGE (number1,[number2],…)….