+ Reply to Thread
Results 1 to 9 of 9

Working hour calculations between two dates excluding sunday, holiday and lunch break

  1. #1
    Registered User
    Join Date
    04-10-2016
    Location
    Mumbai
    MS-Off Ver
    2007
    Posts
    3

    Working hour calculations between two dates excluding sunday, holiday and lunch break

    Hi All,

    I have been searching a lot to get the right formula to calculate the working hours between two dates. Below is the scenario

    Working hours
    Monday to Friday - 9.00 AM to 6.00 PM
    Saturday - 9.00 AM to 2.00 PM

    Now I wan to calculate the working hour between two days excluding Sunday, holidays and also lunch breaks ( Monday to Saturday - 1 PM to 2 PM)

    Networkdays fucntion will not be useful as it excludes Saturday also.

    Lets Say I have two dates

    StartDate - 8/4/2016 10:00:00
    EndDare - 11/4/2016 12:00:00

    So total working hours - (8+4+0+3 = 15 hours)

    Can someone please help me to achieve this?
    Last edited by kush141087; 04-12-2016 at 12:02 AM.

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

    Re: Working hour calculations with tough scenario

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    04-10-2016
    Location
    Mumbai
    MS-Off Ver
    2007
    Posts
    3

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    Thanks. I have done the changes, can you please help me now?

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,750

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    This uses some brute force. Without the NETWORKDAYS.INTL function dealing with the holidays was challenging.

    With a lookup table in K1:Q5 (start - end times against days of the week), holidays in R9:R11 and dates / times in A1:D1 this array entered formula in F1
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.

    The formula yields a 3 row array of 15s. The only way I could find to return one of them was to wrap an INDEX function around it.

    I'm hoping someone will come along with a more elegant solution.

    File attached.
    Dave

  5. #5
    Registered User
    Join Date
    04-10-2016
    Location
    Mumbai
    MS-Off Ver
    2007
    Posts
    3

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    Hi,

    But output I need is 15, you are getting 10

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,750

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    Quote Originally Posted by kush141087 View Post
    Hi,

    But output I need is 15, you are getting 10
    I was getting 15 at my end.

    What dates are in the holidays list?

    Oh yes the dates in the upload are m/d/yyyy format.

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,750

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    I’ve had a chance to work on this some more.

    These formulas work with two assumptions:
    • Since the start / end dates also have start / end times it is assumed these days are neither holidays nor Sundays
    • and all days between those days are assumed to be full days (except holidays and Sundays).

    This has a lookup table in I1:O5. The numbers in row 1 are the WEEKDAY numbers 1-7 Sun-Sat.
    The rest of the lookup table lists the start times / end times each day and the full hours for each day minus lunch.
    Holidays are listed in column O.

    For convenience only there is a summary list of named ranges in H11:I15. The list has no other function. By-the-way Holidays is a Dynamic Named Range (DNR). If you are not familiar with DNRs they shrink and grow automatically as dates are deleted / added.

    The formulas all refer to these named ranges.

    To make it easier to explain there is a formula in F1 that allowed me to break down the final mega-formula in F2 (and F3; see below) into parts.

    The parts are in F10:F13. I left them there to make reviewing easier. They only affect F1. In F2 I simply replaced the cells referenced in F1 with each of those formulas. They can be deleted when you are satisfied they work if you like, but they might make future edits and debugging easier if left.

    Those formulas are … from F10 to F13 all array-entered. They are:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The final mega-formula array-entered in F2 is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    You can of course reduce this further combining terms and then multiplying.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I tested this extensively … different start / end dates … start / end times … holidays. It works.

    Someone can probably simplify / shrink this further. I have been unable to do that.
    If you get a chance to upgrade I would encourage it. I was surprised to find what a problem solver MODE.MULT is. It can reduce this workday / holidays calculation, but it is not available until version 2010.
    Last edited by FlameRetired; 04-16-2016 at 02:49 PM.

  8. #8
    Registered User
    Join Date
    11-02-2017
    Location
    INDIA
    MS-Off Ver
    MS OFFICE 10
    Posts
    1

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    Hi

    The above is not working if the start dates and end dates are same

    Regards
    Prasant

  9. #9
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    19,043

    Re: Working hour calculations between two dates excluding sunday, holiday and lunch break

    Hello po7nair and Welcome to Excel Forum.
    You are replying to a thread that has been dormant for over a year and a half. Please start a new thread and provide a link to this one if it is relevant to some question/issue that you need answered/resolved.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

+ 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] Formula to convert 24 hour day to 8 hour (working) day?
    By miro2021 in forum Excel General
    Replies: 4
    Last Post: 07-31-2017, 10:06 AM
  2. Replies: 4
    Last Post: 10-02-2015, 10:00 AM
  3. Replies: 3
    Last Post: 05-14-2015, 07:32 AM
  4. How to: Miles per hour calculations
    By CarlZ993 in forum Excel General
    Replies: 4
    Last Post: 12-19-2014, 09:20 PM
  5. Calculate employees working from hour to hour
    By otter in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-03-2014, 08:57 AM
  6. [SOLVED] Working out Calls Per Hour. 8 Hour Day.
    By sturmy in forum Excel General
    Replies: 3
    Last Post: 03-24-2014, 11:05 AM
  7. [SOLVED] 24 Hour Calculations
    By Nen in forum Excel General
    Replies: 2
    Last Post: 06-14-2005, 04:05 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