+ Reply to Thread
Results 1 to 5 of 5

Calculatuing Night Differential from start and end times that pass midnight

Hybrid View

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

    Calculatuing Night Differential from start and end times that pass midnight

    Hello,

    I am trying to calculate how many hours one gets night differential for where sometimes the start time is "bigger" than the end time.

    One gets diffferential for hours worked between 18:00 and 09:00 (except for shifts that start between 0600 and 0900).
    So if you start at 23:00 and work until 10:00 the next morning, you get night diff for the hours from 23:00 until 09:00, so I want the formula to produce "10"
    If you start at 0700 and work until 12:00, you get no night diff so "0"
    If you have a weird shift and work from 0700 around the clock until 02:00 the next morning you, get night diff only from 1800 until 0200 the next morning (not those first two hours in the beginning) so answer is "8"
    My formula only works sometimes (see file).

    IF(B2<A2,(1+B2-TIME(18,0,0)),MAX(0,B2-TIME(18,0,0))) is not working for me but I have tried others to no avail.

    Part of my basic problem is a limited understanding of the different time functions and formats and how they affect formulas they are used in.

    Any help would be greatly appreciated!

    night diff formulas forum.xlsx

    -Dan

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,677

    Re: Calculatuing Night Differential from start and end times that pass midnight

    Why isn't C10 15:00? Assuming that's right try this formula in C2 copied down

    =D2-(B2<A2)*3/8-MEDIAN(B2,"9:00","18:00")+MEDIAN(A2,"6:00","18:00")
    Audere est facere

  3. #3
    Registered User
    Join Date
    02-03-2013
    Location
    Europe
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Calculatuing Night Differential from start and end times that pass midnight

    Ahhhh! you're right, C10 should have been 15 (need another coffee).

    Median of time it is then, it works perfectly...but you knew that.

    Thanks for the help!
    Last edited by D J; 02-16-2013 at 11:30 AM. Reason: my poor grammer

  4. #4
    Valued Forum Contributor
    Join Date
    02-05-2013
    Location
    Jakarta, Indonesia
    MS-Off Ver
    Excel 2013
    Posts
    571

    Re: Calculatuing Night Differential from start and end times that pass midnight

    Like daddylonglegs said: "Why isn't C10 = 15:00? ..."

    here another way to get the time, base on your formula:
    =IF(B10<A10,IF(A10>TIME(18,0,0),1-A10+B10,(1+B10-TIME(18,0,0))),MAX(0,B10-TIME(18,0,0)))
    Regards,
    SDCh
    Last edited by SDCh; 02-16-2013 at 11:26 AM.

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

    Re: Calculatuing Night Differential from start and end times that pass midnight

    Quote Originally Posted by SDCh View Post
    Like daddylonglegs said: "Why isn't C10 = 15:00? ..."

    here another way to get the time, base on your formula:
    =IF(B10<A10,IF(A10>TIME(18,0,0),1-A10+B10,(1+B10-TIME(18,0,0))),MAX(0,B10-TIME(18,0,0)))
    Regards,
    SDCh

    That worked just as well!

    Thanks!

+ 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