+ Reply to Thread
Results 1 to 9 of 9

How to calculate night time over midnight

  1. #1
    Registered User
    Join Date
    01-03-2013
    Location
    Mongolia
    MS-Off Ver
    Excel 2010
    Posts
    5

    How to calculate night time over midnight

    Hi all,

    How to calculate night time over midnight. Night time means 22:00-06:00.
    Please see attached excel file.

    Formula at D18 is ok when stop time is between 24:00. But stop time above 24:00 result is 0:00.
    This is time only situation.

    Please help me for solve this problem.

    salary_production12_12test.xlsm

  2. #2
    Forum Contributor dogberry's Avatar
    Join Date
    07-15-2012
    Location
    Wales, UK
    MS-Off Ver
    Excel 2010
    Posts
    624

    Re: How to calculate night time over midnight

    Hi

    Your file is password protected try formatting your cells in [h]:mm format.


    Chris
    Click my star if I helped Thanks

  3. #3
    Valued Forum Contributor
    Join Date
    08-13-2012
    Location
    Gardony, Hungary
    MS-Off Ver
    Excel 2003
    Posts
    558

    Re: How to calculate night time over midnight

    Hi,

    your attached worksheet is password protected, please remove it.

    edit: the pw protection I mean.
    Last edited by RHCPgergo; 01-04-2013 at 04:07 AM. Reason: clarification

  4. #4
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: How to calculate night time over midnight

    Hi defiesta

    Why upload a password protected sheet!

    How about: =MOD("06:00"-"22:00",1) and format as [h]:mm
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  5. #5
    Registered User
    Join Date
    01-03-2013
    Location
    Mongolia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to calculate night time over midnight

    My bad, password is removed.
    Attached Files Attached Files

  6. #6
    Forum Contributor dogberry's Avatar
    Join Date
    07-15-2012
    Location
    Wales, UK
    MS-Off Ver
    Excel 2010
    Posts
    624

    Re: How to calculate night time over midnight

    Hi

    You have some cells formatted at hh:mm change them all to [h]:mm it should then work for you.


    Chris

  7. #7
    Registered User
    Join Date
    01-03-2013
    Location
    Mongolia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to calculate night time over midnight

    Quote Originally Posted by dogberry View Post
    Hi

    You have some cells formatted at hh:mm change them all to [h]:mm it should then work for you.


    Chris
    Not works!

  8. #8
    Forum Expert
    Join Date
    12-24-2004
    Location
    Sweden
    Posts
    1,256

    Re: How to calculate night time over midnight

    Well, it calculates the night time between 22:00-06:00, in most cases.
    But not in all cases. And, the formula is a bit messy.
    //Ola


    ="08:00"-(IF(("08:00"-MOD(D9+"02:00";1))>0;MOD(D9+"02:00";1);0)+IF(("08:00"-MOD(D10+"02:00";1))>0;"08:00"-MOD(D10+"02:00";1);0))
    D9: Start time
    D10: End time

    Example:
    This works: 22:00-06:00 --> 8hrs, 00:00-06:00 --> 6hrs, 22:00-24:00 or 22:00-00:00 --> 2hrs
    But not: 05:00-23:00 --> Error
    Mark the problem as Solved under the Yellow bar up Top right, under Thread Tools, when you received a solution.
    It saves time, to skip already solved threads.

  9. #9
    Registered User
    Join Date
    01-03-2013
    Location
    Mongolia
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to calculate night time over midnight

    Quote Originally Posted by olasa View Post
    Well, it calculates the night time between 22:00-06:00, in most cases.
    But not in all cases. And, the formula is a bit messy.
    //Ola


    ="08:00"-(IF(("08:00"-MOD(D9+"02:00";1))>0;MOD(D9+"02:00";1);0)+IF(("08:00"-MOD(D10+"02:00";1))>0;"08:00"-MOD(D10+"02:00";1);0))
    D9: Start time
    D10: End time

    Example:
    This works: 22:00-06:00 --> 8hrs, 00:00-06:00 --> 6hrs, 22:00-24:00 or 22:00-00:00 --> 2hrs
    But not: 05:00-23:00 --> Error
    Excel: formula contains error!

+ 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