+ Reply to Thread
Results 1 to 5 of 5

Oil & Gas Detention Formulas with Daily Caps

  1. #1
    Registered User
    Join Date
    07-14-2013
    Location
    Ft. Worth, Texas
    MS-Off Ver
    Excel 2013
    Posts
    3

    Angry Oil & Gas Detention Formulas with Daily Caps

    Hello, all!

    I work for a company that services Oil & Gas wells with sand trucks. When drivers wait to offload their product they are paid for their time. There are boundaries, however, and I need help establishing a formula that accounts for many variables. Here is an example breakdown:

    Driver's appointment is 7/14/13 @ 09:00
    He arrives 7/14/13 @ 08:00
    He does not leave the well until 07/16/13 @ 0130

    Here are some rules we must follow:

    Detention does not start until the appointment (ie: 7/14/13 @ 09:00). You cannot charge detention before then.
    The driver does not start earning money from detention until after the first two hours (ie: 7/14/13 @ 11:00)
    There is a cap on detention: Only 12 hours in a 24 hour period are paid. (ie: 7/14/13 11:00- 7/15/13 @ 23:00). Detention does not start up again until 24 hours after the initial appointment time has passed (ie: 7/15/13 @ 09:00). Once again, the driver gives up the first two hours (7/15/13 @ 11:00) and starts earning again at 7/15/13 @ 11:00.

    If a driver arrives AFTER the appointment time then his detention clock starts from the time he got there, not the appointment time, and he STILL gives up the first two hours. The clock still restarts 24 hours after the driver arrives, not from the appointment time.

    In this example the driver has accumulated 40.5 hours of detention for being on time, but is only 24 hours are billable.
    If he arrived at 15:00 on 7/14/13, he would accumulate 34.5 hours of detention, but only 22.5 hours would be billable.

    Does this make sense? The process, not the practice. I need a formula that gives me the total billable hours of detention based on Appointment Time, Arrival Time, and Departure time. All need dates, because these guys can sit around for a few days.

    Thank you!

  2. #2
    Registered User
    Join Date
    06-22-2013
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    65

    Re: Oil & Gas Detention Formulas with Daily Caps

    PickYerBrain,

    Please see the attached. I could not think of a way to do this with standard Excel functions so I created a custom function called BillableDetentionTime. Code is below.

    Please Login or Register  to view this content.
    In your first example I agree with your total of 24 billable hours, however for the guy who arrives at 3pm I calculate he would get 20.5 billable hours. Can you check this otherwise I will need to look at the logic again.

    Please put lots more examples in to check whether it works OK. If not come back to me with the examples so I can fix up.

    Regards

    David
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    07-14-2013
    Location
    Ft. Worth, Texas
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Oil & Gas Detention Formulas with Daily Caps

    You are correct, it is 20.5, not 22.5. I forgot to remove the first two hours. I will check this out and see how it works with the rest of the workbook. Thank you so much for your help!

  4. #4
    Registered User
    Join Date
    07-14-2013
    Location
    Ft. Worth, Texas
    MS-Off Ver
    Excel 2013
    Posts
    3

    Re: Oil & Gas Detention Formulas with Daily Caps

    This certainly did the trick! Thank you so much!

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

    Re: Oil & Gas Detention Formulas with Daily Caps

    I've marked this thread as SOLVED for you.
    Next time, select Thread Tools from the links above to mark a thread as SOLVED. Thanks.
    _________________
    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!)

+ 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. Generating a detention list
    By rburke in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 02:50 AM
  2. Help with a Detention Calculator
    By Swifthand in forum Excel General
    Replies: 4
    Last Post: 06-09-2009, 12:56 PM
  3. How can I convert all Caps to first letter caps in Excel?
    By in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 09-06-2005, 07:05 AM
  4. [SOLVED] How can I convert all Caps to first letter caps in Excel?
    By in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-06-2005, 06:05 AM
  5. Date & Time Detention Clock Functions
    By Thorrrr in forum Excel General
    Replies: 0
    Last Post: 05-02-2005, 01:06 PM

Tags for this Thread

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