+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : Calculating working hours between dates including weekends

  1. #1
    Forum Contributor
    Join Date
    08-26-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    149

    Calculating working hours between dates including weekends

    Hi All,

    I am needing to calculate the hours between 2 dates (including weekend), but only counting the working hours.

    I have had a go, but my fomula seems to be calculating a different answer, so somewhere along the lines it's just not right!!!

    I have a start date of 29/01/2012 18:34:00 and end date of 30/01/2012 16:39:00, with working hours being Mon - Sun 08:00:00 - 17:30:00.

    I manually worked this out to be 18:09:00, but as you can see on the attachment my formula works it out as 17:05:00!!!

    Anyone see where its gone wrong!!! (has it subtracted the 1:04 on the start date passed teh 17:30:00 threshold!) as i don't want this to happen!!

    cheers

    Donna
    Attached Files Attached Files
    Last edited by Icehockey44; 03-08-2012 at 08:06 AM. Reason: solved

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

    Re: Calculating working hours between dates including weekends

    Hello Donna,

    That formula will only work when the start and end times are within the working hours. Try this formula that should work for any start/end times

    =(INT(B2)-INT(A2))*(D2-C2)+MEDIAN(MOD(B2,1),D2,C2)-MEDIAN(MOD(A2,1),D2,C2)
    Audere est facere

  3. #3
    Forum Contributor
    Join Date
    08-26-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Calculating working hours between dates including weekends

    Excellant worked a treat, as always.

    Thanks for that, I had a feeliong from the other ones that i've done that i had forgotten something important.

    Cheers

    Donna

  4. #4
    Forum Contributor
    Join Date
    08-26-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Calculating working hours between dates including weekends

    Daddylonglegs,

    I am trying to add to your reputation via the *, but it won't let me!!! Sorry

  5. #5
    Forum Contributor
    Join Date
    08-26-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Calculating working hours between dates including weekends

    Hi All,

    is the above formula able to be adapted to accomodate different working hours on the weekend?

    IE

    Mon to Fri 08:00:00 to 17:30:00
    Sat 09:00:00 to 16:00:00
    Sun 09:00:00 to 14:00:00

    the original example solution should read 13hours and 39Mins.

    Cheers

    Donna

  6. #6
    Forum Contributor
    Join Date
    08-26-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Calculating working hours between dates including weekends

    Right, I have nearly go there, thanks to a post from here (history)

    http://www.mrexcel.com/forum/showthr...46#post2113046

    I now need to amend the Holiday list, which is a list of bank holidays which this formula excludes, where as I want them to be included but with sunday business hours (9-2), with exception to 25/12/2012, where we do not offer a service.

    this is the formula that I have got to work:

    =SUMPRODUCT(INT((WEEKDAY(A12-A2:A8)+INT(B12)-INT(A12))/7),D2:D8)-SUMPRODUCT((F2:F10>A12)*(F2:F10<B12),LOOKUP(WEEKDAY(F2:F10),A2:D8))+MOD(B12,1)-MOD(A12,1)+LOOKUP(WEEKDAY(A12),A2:B8)-LOOKUP(WEEKDAY(B12),A2:C8)

    Where
    A12 = Example Start Date/time
    B12 = Example End Date/time
    A2:A8 = Day of the week (1->7 Sunday to Saturday)
    D2:D8 = Number of Business Hours worked by day
    F2:F10 = Bank Holiday list
    B2:B8 = Business Hours by Day
    C2:C8 = Business Finish Hours By Day

    Business Normal working Hours
    Mon-Fri 08:30 - 17:30
    Sat 09:00 - 16:00
    Sun 09:00 - 14:00

    Bank holiday business hours
    09:00 - 14:00

    I have attached an example for you to play with. Although on this example I have added columns next to the Holidays data with the Start/end and total hours, which Have not been used in the successful formula.

    I hope this makes sense.

    I look forward to your help

    Cheers

    Donna
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-26-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2007
    Posts
    149

    Re: Calculating working hours between dates including weekends

    any ideas as to how this can be achieved???

+ 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