+ Reply to Thread
Results 1 to 3 of 3

How to calculate night hours

  1. #1
    Registered User
    Join Date
    02-24-2019
    Location
    London
    MS-Off Ver
    Windows 10
    Posts
    6

    Exclamation How to calculate night hours

    Hi all. Apologies but I am a novice requiring some advice. I have a time sheet which with a start and end time. I can add the times up to give me a running total but I want to have night hours worked total and can't work out how to do it. Night hours are from 11pm to 6am. Hope my question makes sense, and any advice appreciated.

  2. #2
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: How to calculate night hours

    your question makes a lot of sense from experience.. many people struggle with this.. Times are a fraction of 1 so 11pm = 0,958333 6am = 0,25
    and Excel cannot calculate with negative time. there are several ways to go around the problem but the basic Idea is to make the endtime greater then the startvalue.

    If starttime is in a1 and endtime is in B1 then I like to use

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


    The --(A1>B1) is a trick to convert a True or false statement to a 0 or 1.
    So if The starttime (11pm) is greater then end time(6am) it the statment is true or value 1 the sum then becomes 1+0,25-0,958333 = 0,2966667 or 7:00 hours



    Another often used formula is

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


    which comes down to exactly the same as the first solution but might be easier to read / understand what is happening.
    Last edited by Roel Jongman; 02-24-2019 at 10:05 AM.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: How to calculate night hours

    Quote Originally Posted by Sulprobil View Post
    Hello,

    I wrote a VBA function for this: sbCountHours.

    But: I am not allowed to present a link here.

    Regards,
    Bernd P
    Feel free to post your code here, using code tags. What you cannot do is promote your own web site.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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] How to calculate night shift hours?
    By jane_dm7 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-04-2023, 09:52 AM
  2. [SOLVED] Calculate night shift hours on 24 hr schedule
    By megancoleman920 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-31-2019, 12:44 PM
  3. [SOLVED] Calculate hours during set times for night shift allowance
    By mbeire in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-14-2017, 09:32 PM
  4. Replies: 3
    Last Post: 06-18-2014, 07:26 AM
  5. Replies: 4
    Last Post: 09-21-2012, 12:58 AM
  6. [SOLVED] Need to calculate night shift hours
    By avdald in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-23-2012, 02:25 PM
  7. [SOLVED] How do I calculate the number of night hours worked
    By Somlal22 in forum Excel General
    Replies: 3
    Last Post: 08-17-2012, 07:18 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