+ Reply to Thread
Results 1 to 9 of 9

hour difference between two dates/times, exclude weekends and holidays

  1. #1
    Registered User
    Join Date
    12-22-2013
    Location
    united states
    MS-Off Ver
    Excel 2013
    Posts
    64

    hour difference between two dates/times, exclude weekends and holidays

    Hey there, I am hoping someone can help me out with a formula.

    I have two dates and times. I would like to find the difference in hours between the two times. I would also like the formula to exclude weekends/holidays. However, if the "time in" is on a sunday, I would like the formula to magically calculate as if the "time in" is the next business day at 9am.

    My goal is to figure out how much time it takes to review a document from the time that it came in. And if a document came in on a weekend/holiday, to act as if it came in first thing in the morning on the next business day.

    I have attached my workbook for reference. column C has the desired turnaround time.

    Clarification: I would like to find the amount of business working hours between the two times.
    Attached Files Attached Files
    Last edited by lamdl; 01-23-2014 at 06:48 PM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: hour difference between two dates/times, exclude weekends and holidays

    Try NETWORKDAYS()
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    12-22-2013
    Location
    united states
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: hour difference between two dates/times, exclude weekends and holidays

    Quote Originally Posted by protonLeah View Post
    Try NETWORKDAYS()
    This formula yields a turnaround time of 72 hrs. This formula does not account for the weekend. It also does not change the time in to the next business day at 9am

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,613

    Re: hour difference between two dates/times, exclude weekends and holidays

    C2:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-22-2013
    Location
    united states
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: hour difference between two dates/times, exclude weekends and holidays

    Quote Originally Posted by protonLeah View Post
    C2:
    Please Login or Register  to view this content.
    This yields 39 hrs. However, the amount of business hours from monday at 9am until wednesday at 12pm is 51 hrs.

    Clarification: I would like to find the number of business working hours between A2 and B2.
    Last edited by lamdl; 01-23-2014 at 06:49 PM.

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

    Re: hour difference between two dates/times, exclude weekends and holidays

    Is the "time out" ever on a weekend?

    For your example you want the answer 51:00, what if the time in was a Friday at 10:00 and the time out a Monday at 15:00, how many hours is that?
    Audere est facere

  7. #7
    Registered User
    Join Date
    12-22-2013
    Location
    united states
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: hour difference between two dates/times, exclude weekends and holidays

    Quote Originally Posted by daddylonglegs View Post
    Is the "time out" ever on a weekend?

    For your example you want the answer 51:00, what if the time in was a Friday at 10:00 and the time out a Monday at 15:00, how many hours is that?
    In that case, when the "time in" was Friday at 10 am and "time out" on Monday is at 3 PM, the turnaround time would be 14 hrs. I considered 8am-5pm business hrs.

    If the time in was either Saturday or Sunday at 10am, and the time out on monday is at 3pm, the turnaround time would be be 8 hrs (from 8am till 3pm on monday).

    Also, if a time in is on a holiday such as Dec 25th(wed) at 10am and time out is Dec 26th(thurs) at 3pm, the turnaround time would be 8 hrs as well.

    Any "time in" date should be counted as the next business day at 8am. Sorry if this is very confusing. I really appreciate your help on this.

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

    Re: hour difference between two dates/times, exclude weekends and holidays

    OK but given that logic surely Sunday at 12:00 until Wednesday at 12:00 should be 22:00 (8:00 to 17:00 on both Monday and Tuesday and 8:00 until 12:00 on Wednesday)?

    Try this formula

    =(NETWORKDAYS(A2,B2)-1)*("17:00"-"8:00")+MOD(B2,1)-MEDIAN(NETWORKDAYS(A2,A2)*MOD(A2,1),"8:00","17:00")

    That counts all the working hours assuming that B2 will always be within working hours but A2 may not - you can add a holiday range to both NETWORKDAYS functions to exclude holidays too, i.e.

    =(NETWORKDAYS(A2,B2,holidays)-1)*("17:00"-"8:00")+MOD(B2,1)-MEDIAN(NETWORKDAYS(A2,A2,holidays)*MOD(A2,1),"8:00","17:00")

    format result cell as [h]:mm

  9. #9
    Registered User
    Join Date
    12-22-2013
    Location
    united states
    MS-Off Ver
    Excel 2013
    Posts
    64

    Re: hour difference between two dates/times, exclude weekends and holidays

    Quote Originally Posted by daddylonglegs View Post
    OK but given that logic surely Sunday at 12:00 until Wednesday at 12:00 should be 22:00 (8:00 to 17:00 on both Monday and Tuesday and 8:00 until 12:00 on Wednesday)?

    Try this formula

    =(NETWORKDAYS(A2,B2)-1)*("17:00"-"8:00")+MOD(B2,1)-MEDIAN(NETWORKDAYS(A2,A2)*MOD(A2,1),"8:00","17:00")

    That counts all the working hours assuming that B2 will always be within working hours but A2 may not - you can add a holiday range to both NETWORKDAYS functions to exclude holidays too, i.e.

    =(NETWORKDAYS(A2,B2,holidays)-1)*("17:00"-"8:00")+MOD(B2,1)-MEDIAN(NETWORKDAYS(A2,A2,holidays)*MOD(A2,1),"8:00","17:00")

    format result cell as [h]:mm
    Very close. I think I communicated incorrectly.

    Sunday at 12:00 until Wednesday at 12:00 should be 52:00. Time in would start monday at 8:00. tuesday at 8:00 would be 24 hrs. Wed at 8 would be 48 hrs. wed at 12:00 would be 52:00 Since I am concerned with the number of hours during business days, not only business hrs.

+ 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. Replies: 6
    Last Post: 09-09-2013, 08:54 AM
  2. Replies: 4
    Last Post: 03-08-2012, 02:57 PM
  3. Replies: 10
    Last Post: 11-29-2011, 08:21 PM
  4. Replies: 7
    Last Post: 01-11-2011, 06:26 AM
  5. String of dates to exclude weekends AND holidays
    By FEI7774 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-01-2009, 06:19 PM

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