Calculate Hours between two dates without weekend

treeppm

Board Regular
Joined
Jun 3, 2015
Messages
60
Hi fellows.

I have two dates like following

2019-03-07 21:00
2019-03-18 11:00

I would like to know how many hours between these two dates omitting Saturday and Sunday
Kindly guide me for the formula to get results

Kind Regards
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
One simple example with result
date format(yyyy-mm-dd HH:MM)
2019-03-07 21:00
2019-03-11 03:00

between these two values the total hours is 30 (without Saturday Sunday).

what is the formula I can use to get the result 30?..
 
Last edited:
Upvote 0
Hi treeppm,

First format result Cell to [h]

Date cell A1 and B1


formula equals =NETWORKDAYS(A1,B1)-1-MOD(A1,1)+MOD(B1,1)


Enjoy

Hope it helps
 
Upvote 0
Thank you so much for the good help bro., works perfect.
Could you please explain this formula?.. very eager to learn

Kind Regards
 
Upvote 0
Hi Treeppm,
It’s a bit tricky but first of all, you will have to understand how Excel actually stores/uses (Regardless of the format you see or set) dates and Times.

Code:
Microsoft Excel stores dates as sequential serial numbers so they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2019 is serial number 43466 because it is 43,466 days after January 1, 1900.
07/03/2019  21:00:00 = 43531
11/03/2019  03:00:00 = 43535


Microsoft Excel stores times as  decimal number between 0 and 0.999988426 given an hour, minute and second value. A result of 0 represents 12:00:00 AM, 0.25 =  06:00:00 AM, 0.50 =  12:00:00 PM, 0.75 =  06:00:00 PM.
07/03/2019  21:00:00 = 43531.875
11/03/2019  03:00:00 = 43535.125


NETWORKDAYS
Returns the number of whole working days between start_date and end_date. Working days exclude weekends


MOD function
Returns the remainder after number is divided by divisor           MOD(number, divisor)


In your case, the Calculation is as follows (Remember that dates are just Numbers)
=NETWORKDAYS(A1,B1)-1-MOD(A1,1)+MOD(B1,1)
NETWORKDAYS(A1,B1)           
Answer:         = 3           number of whole working days
NETWORKDAYS(A1,B1)-1
Answer:         = 2           number of whole working days but we want the difference not the total whole number
MOD(A1,1)
Answer:         = 43531.875 - 43531   which  = 0.875   then Divide this by 1  which =  0.875
MOD(B1,1)
Answer:         = 43535.125- 43535   which  = 0.125   then Divide this by 1  which =  0.125
Therefore your answer =
2 - 0.875 + 0.125 = 1.25               Convert this to a date and you get  01/01/1900 06:00    (1.25 in Numerical terms)
Finally, we can format the cell as [h] which gives the answer as (1 Whole day + ¼ of a day) gives total hours of 30
If you format the cell to [h]:mm   (This would give total hours and minutes your answer would be 30:00
Hope that this is clearer than mud to you.

Hope that this is clearer than mud to you.
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top