+ Reply to Thread
Results 1 to 8 of 8

computing night working time

  1. #1
    Registered User
    Join Date
    05-01-2010
    Location
    Zamora, Spain
    MS-Off Ver
    Excel 2007
    Posts
    6

    computing night working time

    Hello
    I need to calculate night working time.
    I must have a column to register every day "start time" and another one to register “end of time".
    I need to get automatically:
    - "worked time" - for this one I don't need help.
    - "night time" - this is the problem.
    The night time is between 20:00 and 06:00 (next day).
    Is it possible to do this without macros?
    Thank you for your help.
    Last edited by fatbird; 05-02-2010 at 04:40 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: computing night working time

    This might help,the site also has a lot of information on calculating times
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    05-01-2010
    Location
    Zamora, Spain
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: computing night working time

    Quote Originally Posted by royUK View Post
    This might help,the site also has a lot of information on calculating times
    Thank you very much.
    It`s an interesting and useful web which is already in my bookmarks. Anyway it could not solve my problem.

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

    Re: computing night working time

    Hello fatbird,

    Assuming you have a start time in A2 and end time in B2 then this formula in C2 will give the total hours worked

    =MOD(B2-A2,1)

    then in D2 use this formula to calculate all hours between 20:00 and 06:00

    =C2-(A2>B2)*MEDIAN(0,B2-1/4,7/12)-MAX(0,MIN(5/6,B2+(A2>B2))-MAX(1/4,A2))

    format all cells as time

  5. #5
    Registered User
    Join Date
    05-01-2010
    Location
    Zamora, Spain
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: computing night working time

    Quote Originally Posted by daddylonglegs View Post
    Hello fatbird,

    Assuming you have a start time in A2 and end time in B2 then this formula in C2 will give the total hours worked

    =MOD(B2-A2,1)

    then in D2 use this formula to calculate all hours between 20:00 and 06:00

    =C2-(A2>B2)*MEDIAN(0,B2-1/4,7/12)-MAX(0,MIN(5/6,B2+(A2>B2))-MAX(1/4,A2))

    format all cells as time
    No way!

    I applied both formulas, changing "," by ";" (Excel 2007).
    I tried several time formats and I just got "#N/A" in C2 and D2.
    Are you sure about using "MOD" in tht first one?

    Thank you anyway, daddylonglegs.

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

    Re: computing night working time

    Quote Originally Posted by fatbird View Post
    Are you sure about using "MOD" in tht first one?
    Yes, it's not the only way....but it's one way to do it....see the attached example
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    05-01-2010
    Location
    Zamora, Spain
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: computing night working time

    Quote Originally Posted by daddylonglegs View Post
    Yes, it's not the only way....but it's one way to do it....see the attached example
    Outstanding!
    Thank you very much, daddylonglegs.
    You have been very helpful and nice. That's exactly what I need.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: computing night working time

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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