+ Reply to Thread
Results 1 to 7 of 7

Calculate time for working hours when start time falls outside of working hours

  1. #1
    Registered User
    Join Date
    01-15-2014
    Location
    Utah, USA
    MS-Off Ver
    Excel 2013
    Posts
    3

    Calculate time for working hours when start time falls outside of working hours

    Hey All,

    It's my first time posting in these forums and I would like to first state that I have searched all over for the answer to this, but had no luck finding the answer to my specific question.

    I am trying to calculate the time it takes from the moment a PO is received by our office (via email), to the time it is entered by us. I have had luck thus far in calculating for net work days only (Mon-Fri) and our hours of operation (8:30am-5:30pm) but the problem arises when a PO is received after normal working hours. For example, if a PO arrives Saturday at 12:00pm, and it was entered on Monday morning at 9:00am, the calculation should only be that it took 0.5 hours (or 30 mins) of working hours for the PO to be entered.

    Instead of 30 mins, I am getting 6 hours (because it is now counting the remaining 5:30 on Saturday, excluding Sunday, and then adding the correct 30 mins on Monday). Do any of you guys know how I would go about fixing this problem?

    Attached is an example spreadsheet of what I am trying to work out.

    Thanks!
    Logbook problem.xlsx
    Last edited by SKDY_Beau; 01-20-2014 at 12:53 PM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Calculate time for working hours when start time falls outside of working hours

    Working with dates and times is always a pain in the neck. Normally, I would recommend a bunch of helper columns to keep all the date and time checking straight, but here it is all at once. In J4:
    Please Login or Register  to view this content.
    Last edited by Pauleyb; 01-17-2014 at 05:47 PM.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

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

    Re: Calculate time for working hours when start time falls outside of working hours

    This formula in O4 will give you the required results

    =24*((NETWORKDAYS(B4,D4,N$4)-1)*(M$4-L$4)+E4-MEDIAN(C4*NETWORKDAYS(B4,B4,N$4),L$4,M$4))

    format as number and copy down
    Audere est facere

  4. #4
    Registered User
    Join Date
    01-15-2014
    Location
    Utah, USA
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Calculate time for working hours when start time falls outside of working hours

    Hey guys,

    Thanks for the attempts to help but it seems that neither of those formulas quite work for a situation in which the "start time" is before 8:30am. Daddylonglegs, your formula was closest but attached is an example of a situation in which it produces a negative value for the elapsed time. Any ideas of how to fix this? If not, no worries and thank you for your time. The fix I have come up with in the mean time is to just enter "8:31am" as the start time for POs received outside of working hours.
    Excel Example.xlsx

  5. #5
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Calculate time for working hours when start time falls outside of working hours

    I think mine still works if you read what I provided. My calculation was to go into the J column and it generates a new start time. You can then use it for your calculations. My result is a date and time, so be sure it is formatted as a date and time, otherwise it looks like numbers in the 40,000s.

    In your second spreadsheet my formula creates 1/20/2014 8:30am for the highlighted row.

    I am thinking DaddyLongLegs method may provide a cleaner solution, but I would have to parse it first.

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

    Re: Calculate time for working hours when start time falls outside of working hours

    The formula I suggested handles start times before 08:30 OK.....the problem with that example is that 18/01/2014 was a Saturday so you actually have the "entered" time/date outside working hours, my asumption was that the entered time would always be within working hours. If you leave the times the same but change the date (on both Received and Entered) to 17/01/2014 then you'll get 7.85 as required

    If you do need to handle "Entered" times that are outside working hours (but still count only the actual working hours, so 06:23 on 18th Jan 2014 to 16:21 on 18th Jan 2014 will be zero working hours because it starts and ends on the same Saturday) then use this version

    =24*((NETWORKDAYS(B4,D4,N$4)-1)*(M$4-L$4)+IF(NETWORKDAYS(D4,D4),MEDIAN(E4,L$4,M$4),M$4)-MEDIAN(C4*NETWORKDAYS(B4,B4,N$4),L$4,M$4))

    If you want you can also add another IF function so that you get a blank unless all 4 values are populated, e.g.

    =IF(COUNT(B4,C4,D4,E4)=4,24*((NETWORKDAYS(B4,D4,N$4)-1)*(M$4-L$4)+IF(NETWORKDAYS(D4,D4),MEDIAN(E4,L$4,M$4),M$4)-MEDIAN(C4*NETWORKDAYS(B4,B4,N$4),L$4,M$4)),"")

  7. #7
    Registered User
    Join Date
    01-15-2014
    Location
    Utah, USA
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Calculate time for working hours when start time falls outside of working hours

    Daddylonglegs, thank you! That works perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Calculate response time in working hours between two dates
    By ajagibson in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-28-2021, 08:45 AM
  2. Calculate start date & time of task (working hours)
    By kaaver in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-30-2016, 10:56 AM
  3. If time period falls outside of normal working hours how many hours does it add.
    By chrisdromey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2013, 11:56 PM
  4. Calculate finish time given start time, working hours and job duration
    By swanseaexcel in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-23-2012, 03:00 PM
  5. calculate the amount of time between 2 dates (working hours)
    By rickyRRE in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-23-2012, 10:03 AM

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