+ Reply to Thread
Results 1 to 6 of 6

Help on calculating extra pay

Hybrid View

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    3

    Help on calculating extra pay

    I hope someone could help me with this riddle.
    Extra pay is given when start and end time is within 8:00 AM to 4:00 PM, so that's a total of 8 hrs
    e.g.
    1. 5:00 AM - 4:00 PM - should have 8hrs full extra pay
    2. 3:00 PM - 2:00 AM - should have get only 1hr extra pay
    3. 12:00 AM - 9:00 AM - should get only 1hr extra pay
    4 . 7:45 AM - 6:45 PM - should have 8hrs full extra pay

    please see attached for the format needed. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help on calculating extra pay

    Assuming:

    A1: 3:00 PM
    B1: 2:00 AM

    C1: =IF((MEDIAN("8:00 AM", "4:00 PM", B1)-MEDIAN("8:00 AM", "4:00 PM", A1))*24<0, (1-MEDIAN("8:00 AM", "4:00 PM", B1)-MEDIAN("8:00 AM", "4:00 PM", A1))*24, (MEDIAN("8:00 AM", "4:00 PM", B1)-MEDIAN("8:00 AM", "4:00 PM", A1))*24)


    This shorter version almost works:

    C1: =((MEDIAN("8:00 AM", "4:00 PM", B1)-MEDIAN("8:00 AM", "4:00 PM", A1))*24)+(A1>B1)

    ...but is missing the example above. It gets all your other examples right. Still musing over that.

    http://screencast.com/t/7D4JqbskQK
    Last edited by JBeaucaire; 09-28-2012 at 09:28 AM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: Help on calculating extra pay

    You need to multiply the last part by the length of the period, Jerry, (8 AM to 4 PM), e.g.

    =(MEDIAN("8:00 AM", "4:00 PM", B2)-MEDIAN("8:00 AM", "4:00 PM", A2))*24+(A2>B2)*8

    or explicitly linking the start/end times

    =(MEDIAN("8:00 AM", "4:00 PM", B2)-MEDIAN("8:00 AM", "4:00 PM", A2)+(A2>B2)*("4:00 PM"-"8:00 AM"))*24
    Audere est facere

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help on calculating extra pay

    Awesome as always, DDL. Thanks.

  5. #5
    Registered User
    Join Date
    09-27-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Help on calculating extra pay

    Thank you Jbeaucaire and Daddlylonglegs! You're amazing! the first one Jbeaucaire's formula worked for my file. However with start time of 6pm - 3am, i got this 2.66454E-15. How should I get rid of this? please see attached file again provided both formulas given... thank you! EXTRA PAY (1).xls

  6. #6
    Registered User
    Join Date
    09-27-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Help on calculating extra pay

    I tried the other formula Daddylonglegs gave! it worked! thank you! EXTRA PAY (1).xls

+ 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