How come this works????

gtag44

New Member
Joined
Feb 6, 2021
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'm going crazy.

Have a look here
Get Excel Jet : work hours between dates and times

VBA Code:
=(NETWORKDAYS(start,end)-1)*(upper-lower)
+IF(NETWORKDAYS(end,end),MEDIAN(MOD(end,1),upper,lower),upper)
-MEDIAN(NETWORKDAYS(start,start)*MOD(start,1),upper,lower)

Looking at it NETWORKDAYS(end,end) and NETWORKDAYS(start,start) , as there are 0 days between end-end and start-start , should evaluate to 0 so that the formula could be reduced to

Code:
=(NETWORKDAYS(start,end)-1)*(upper-lower)
+IF(0,lower,upper)
-MEDIAN(0,upper,lower)

And because IF(0) -> FALSE, and MEDIAN(0, latetime, earlytime)-> earlytime (upper late time, lower = early time) shoulf further reduce to
Code:
=(NETWORKDAYS(start,end)-1)*(upper-lower)
+ upper
- lower


But - it does not give the same result...

What am I not seeing here ??
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi & welcome to MrExcel.
The easiest way to see what a formula is doing, is to use the Evaluate Formula button on the formula tab.
 
Upvote 0
Hi & welcome to MrExcel.
The easiest way to see what a formula is doing, is to use the Evaluate Formula button on the formula tab.
Thank you for the warm welcome.

I'm aware of the Evaluate, and looking at the evaluation NETWORKDAYS gives different results depending on

If start date is a date (numbervalue = 44125) or a timedate (numbervalue =44125,56757)

in the first case NETWORKDAYS(start, start) ->0
in the second NETWORKDAYS(start, start) ->1

and that baffles me, as the real time difference in both cases (and especially the second) is 0


 
Upvote 0
If the start date is a weekend you'll get 0, otherwise you'll get 1.
the NETWORKDAYS(start, start) has nothing to do with time.
 
Upvote 0
Solution
If the start date is a weekend you'll get 0, otherwise you'll get 1.
the NETWORKDAYS(start, start) has nothing to do with time.

Really ? 44125 and 44125,56757 is both on Monday September 21st 2020.

NETWORKDAYS() - is according to the description, specifically about time :
NETWORKDAYS function - def
Returns the number of whole working days between start_date and end_date. Working days exclude weekends and any dates identified in holidays. Use NETWORKDAYS to calculate employee benefits that accrue based on the number of days worked during a specific term.
 
Upvote 0
Networkdays calculates days, not time.
The time element is irrelevant, as can be seen by this
+Fluff 1.xlsm
BCDE
621/10/2020 18:5621/10/2020 13:371
Main
Cell Formulas
RangeFormula
E6E6=NETWORKDAYS(B6,C6)
 
Upvote 0
A day is a span of time on the time vector. A day is a unit of time just a a second, a minute, an hour. It's about time.
 
Upvote 0
It is not about time. It is about Integers starting from 1/1/1900, i.e. days
 
Upvote 0
Ok as you want to be very pedantic I should have said
the NETWORKDAYS(start, start) has nothing to do with the time element of the date. (ie the decimal part of the number)
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

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