+ Reply to Thread
Results 1 to 5 of 5

Date Calculation using NETWORKDAYS

  1. #1
    Registered User
    Join Date
    09-24-2008
    Location
    London UK
    Posts
    18

    Date Calculation using NETWORKDAYS

    Hi - it's me again.

    I'm producing a spreadsheet showing jobs outstanding on a helpdesk system. I have a title at the top reading 'Oustanding jobs as at' and have isolated the next cell which contains the function =TODAY(). In the body of the sheet is a columnar list of outstanding jobs with one column showing the date the job was submitted. The next column is headed 'Days Outstanding' and contains the formula = NETWORKDAYS(E1,D5) (where E1 is the isolated cell in the title and D5 is the first cell containing an outstanding job submission date). All relevant cells are formatted to 'Date' in the 19/3/2010 format.

    This is returning a number of days outstanding for each job, which is what I expected. The problem is that a job logged today is shown as being one day outstanding, and a job logged yesterday as two days. Obviously anything logged today should be returning a value of zero, and all my figures are out by one day.

    Two questions:

    1) Why is this happening? Excel processes dates, however they are shown, as numbers. A particular date must represent a particular number, and when you subtract a number from itself the answer is inevitably zero. I really don't understand this at all.

    2) How can I fix it? I tried the obvious by appending -1 to the end of the function but it threw a hissy fit and decided to return a date of 1/1/1900, which really wasn't helpful!

    Many thanks in advance for hopefully solving a numpty's second query in two days. My first was resolved yesterday, only a couple of working hours after I posted it, which |I think is awesome!
    Last edited by Moondog; 03-19-2010 at 12:39 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Date Calculatiion using NETWORKDAYS

    NETWORKDAYS treats the days as being inclusive - ie if you started work today and left work today you worked 1 day not 0 days.

    To make exclusive you should as you have already outlined - subtract 1 from the result - ie NETWORKDAYS(E$1,D5)-1

    Ensure the cell is formatted as General ... 1 in date form would show as 01/01/1900 whereas 0 would show as 00/01/1900
    Last edited by DonkeyOte; 03-19-2010 at 07:53 AM. Reason: typo

  3. #3
    Registered User
    Join Date
    09-24-2008
    Location
    London UK
    Posts
    18

    Re: Date Calculatiion using NETWORKDAYS

    Why is it that I cane my brain looking for the solution, and yet when someone gives it to you it seems so obvious?

    Thank you, DonkeyOte. It seems I was doing everything right except formatting the cells to 'General'! It appears that the cells were autoformatting themselves to 'Date', probably because of the two date formats contained in the function.

  4. #4
    Registered User
    Join Date
    07-05-2011
    Location
    ohio
    MS-Off Ver
    Home and Business 2010
    Posts
    5

    Re: Date Calculation using NETWORKDAYS

    Old thread, but I found it when searching and there is no acceptable answer yet so I wanted to answer it as it might help someone else in the future.

    The problem with just subtracting 1 from the result is that it assumes your start date is a workday; the result will be wrong if your start date is a weekend or holiday.
    What you need is to subtract a day if your start date is a workday, but subtract zero days if it's not a workday.

    We can check if a date is a workday or not using networkdays with the same start and end date.
    Please Login or Register  to view this content.
    When A1 is a workday this will return 1. When A1 is a weekend or holiday this will return 0.
    So knowing that we can calculate the non-inclusive number of days by subtracting the result of that check from our original networkdays result.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Date Calculation using NETWORKDAYS

    And for completeness......

    If A2 is an earlier date than A1 NETWORKDAYS can return a negative number, in which case rather subtracting 1 you would need to add 1 - to take care of that you can use this version:

    =NETWORKDAYS(A1,A2,holidays)-SIGN(NETWORKDAYS(A1,A1,holidays))
    Audere est facere

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1