+ Reply to Thread
Results 1 to 3 of 3

Help with NETWORKDAYS function to calculate within date ranges

  1. #1
    Registered User
    Join Date
    04-09-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    Help with NETWORKDAYS function to calculate within date ranges

    I am looking for some assistance with using the networkdays function. I have some data from our hire system that gives the Hire Start & Hire End dates, and I need to calculate the number of days between the two dates to return two results. I first need the Total Hire period in days regardless of when it started or ended, and secondly, the number of days that the hire was active in the current reporting period, which I specify in two cells on the sheet. The problem comes when I have to take account of some conditions. Firstly, the Hire End date is sometimes blank if it is an ongoing hire - in this case the calculation A should end on the Report End date. Secondly, sometimes the hire falls totally before the reporting period - in this case the Total Hire period should return the number of working days, but the Hire Days this Period should be set to 0. Thirdly, there are also some occasions where the hire is a future hire, ie the Hire Start date is after the current reporting period - in this case both columns should be set to 0 (not minus). Finally, sometimes there are error corrections from the hire system where the Hire End is before the Hire Start - in this case both columns should be set to 0 as well.

    I know how to use networkdays, but I've tried various combinations of nested IF statements and I can't seem to get them to take account of all my conditions. To show what I mean I've attached a screenshot with some sample data. The columns in red are the two calculations I need to return. In this example, I have shown the values that *should* be returned in red, these are not what I actually get however.

    Hire Dates Calculation.jpg

    Thank you in advance for your assistance.

    Martyn

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

    Re: Help with NETWORKDAYS function to calculate within date ranges

    Hello Martyn,

    I'm not sure I agree with all your results - how is E7 = 21 or D10 = 48?

    Try this formula in D6 copied down

    =IF(B6="","",MAX(0,NETWORKDAYS(B6,IF(C6="",B$3,C6))))

    and this one in E6

    =IF(B6="","",MAX(0,NETWORKDAYS(MAX(B6,B$2),MIN(IF(C6="",B$3,C6),B$3))))
    Audere est facere

  3. #3
    Registered User
    Join Date
    04-09-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Help with NETWORKDAYS function to calculate within date ranges

    Thank you - this works perfectly!

    I had tried to count the days manually on the calendar for my example (hence the wrong values in E7/D10) - I was getting tired!


    Your help much appreciated!

    Best regards
    Martyn

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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