+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : Networking hours when service window end time is less than service window start time

  1. #1
    Registered User
    Join Date
    11-26-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    3

    Networking hours when service window end time is less than service window start time

    Hi,

    Am currently using Excel 2007

    I have a scenario where i need to calculate net working hours between 2 dates, excluding weekends. The recognized working hours in a day(Mon to Fri) are from 09:00 AM to 01:30 AM (next day morning). If someone works outside this service window, those hours are not counted

    E.g 1 If i start on 28th Nov, 2011 at 9 AM and end on 29th Nov, 2011 at 9 AM - the net working hours should be 16.5 hrs
    E.g 2 If i start on 28th Nov, 2011 at 8 AM and end on 29th Nov, 2011 at 9 AM - the net working hours should be 16.5 hrs
    E.g 3 If i start on 28th Nov, 2011 at 10 PM and end on 29th Nov, 2011 at 9 AM - the net working hours should be 3.5 hrs
    E.g 3 If i start on 27th Nov, 2011 at 10 PM and end on 29th Nov, 2011 at 9 AM - the net working hours should be 16.5 hrs

    I have tried formula from below but it fails as the working hours end time (01:30 AM) is lesser than start time (09:30 AM)

    =IF(M3<>"",(NETWORKDAYS(G3,M3,$AW$2:$AW$15)-1)*($AY$2-$AX$2)+IF(NETWORKDAYS(M3,M3,$AW$2:$AW$15),MEDIAN(MOD(M3,1),$AY$2,$AX$2),$AY$2)-MEDIAN(NETWORKDAYS(G3,G3,$AW$2:$AW$15)*MOD(G3,1),$AY$2,$AX$2),"NA")

    where G3 = Start date
    M3= End Date
    $AW$2:$AW$15 = Holiday List
    $AY$2 = 01:30 AM
    $AX$2= 09:00 AM


    Any support on this would be very helpful

    Regards,
    V
    Last edited by vinaykora; 11-27-2011 at 02:59 AM. Reason: Updating Excel version to Excel 2007

  2. #2
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Networking hours when service window end time is less than service window start t

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook. Don't upload a picture when you have a workbook. None of us is inclined to recreate your data. Upload the workbook and manually add an 'after' situation so that we can see what you expect. In addition clearly explain how you get the results.

    To attach a file to your post, you need to be using the main 'New Post' or 'New Thread' page and not 'Quick Reply'.
    To use the main 'New Post' page, click the 'Post Reply' button in the relevant thread.

    On this page, below the message box, you will find a button labelled 'Manage Attachments'.
    Clicking this button will open a new window for uploading attachments.

    You can upload an attachment either from your computer or from another URL by using the appropriate box on this page.
    Alternatively you can click the Attachment Icon to open this page.

    To upload a file from your computer, click the 'Browse' button and locate the file.

    To upload a file from another URL, enter the full URL for the file in the second box on this page.
    Once you have completed one of the boxes, click 'Upload'.

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    Would you like to say thanks? Please click the: " Add Reputation" button, on the grey bar below the post.

  3. #3
    Registered User
    Join Date
    11-26-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Networking hours when service window end time is less than service window start t

    Hi,

    Thanks for the input, Moderator. Apologies as i am new here.

    Am uploading a spreadheet to illustrate the problem and approach being taken. Have simplified the file and Column C is where i am calculating the desired hours - This contains the simplified formula too ( which i had pasted in my previous post)

    Hope this helps in clarifying the issue better

    Rgds
    Attached Files Attached Files

  4. #4
    Forum Expert ConneXionLost's Avatar
    Join Date
    03-11-2009
    Location
    Victoria, Canada
    MS-Off Ver
    2010
    Posts
    2,952

    Re: Networking hours when service window end time is less than service window start t

    In situations where the end time is smaller than the start time, you'll need to add a day (1), so the calculation knows it is still "larger". Give this a try:

    Please Login or Register  to view this content.
    Cheers,

  5. #5
    Forum Expert darkyam's Avatar
    Join Date
    03-05-2008
    Location
    Houston, TX
    MS-Off Ver
    2013
    Posts
    2,191

    Re: Networking hours when service window end time is less than service window start t

    Rather than MAX($I$2-$H$2,($I$2+1)-$H$2), you can use MOD($I$2-$H$2,1). Shorter and easier to debug. Same for replacing your If statement later on that does the same thing.
    Life is about perseverance. Remember: today's mighty oak tree is just yesterday's nut that held its ground.

    If you like a post, please rate it with the scales icon (top right).
    If you feel really indebted, please consider a donation to charity, such as Feed the Children or Habitat for Humanity.

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

    Re: Networking hours when service window end time is less than service window start t

    So the working hours on a Friday would be 09:00 on Friday until 01:30 on Saturday morning?

    The suggestions posted so far won't deal correctly with finish times at 01:00, e.g. Thursday 21:00 to next day at 01:00 should be 4:00 hours

    To cope with any start or end time and any period in H2/I2 - either on the same working day or crossing midnight - you can use this version

    =IF(B2<>"",(NETWORKDAYS(A2-H$2,B2-H$2,G$2:G$15)-1)*MOD(I$2-H$2,1)+IF(NETWORKDAYS(B2-H$2,B2-H$2,G$2:G$15),MIN(MOD(I$2-H$2,1),MOD(B2-H$2,1)),MOD(I$2-H$2,1))-MIN(NETWORKDAYS(A2-H$2,A2-H$2,G$2:G$15)*MOD(A2-H$2,1),MOD(I$2-H$2,1)),"N/A")
    Audere est facere

  7. #7
    Registered User
    Join Date
    11-26-2011
    Location
    hyderabad
    MS-Off Ver
    Excel 2007
    Posts
    3

    [SOLVED]:Networking hours when service window end time is less than service window

    This is truly a life saver forum. Amazing depth of skills!

    Thanks so very much, Daddylonglegs, darkyam, ConneXiounlost

    Cheers

+ 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