+ Reply to Thread
Results 1 to 8 of 8

I need to find a formula that calculates how much time falls into a certain criteria.

  1. #1
    Registered User
    Join Date
    10-04-2016
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    4

    I need to find a formula that calculates how much time falls into a certain criteria.

    I'm looking for some answers
    I work different shifts, every single week. I would like to get Excel to work out how much I should get paid. The thing is my shift I never the same 2 weeks in a roll and hardly ever repeat themselves.
    The constant are That after what time on what day I got what kind of bonus. so if I have a night shift from let's say 10 p.m. 10 a.m. starting on a Sunday night I get my base salary + sunday bonus + night bonus from midnight until 6 a.m.

    Normally I have 2 columns with dates and times like 02/10/2016 22:00:00 and 03/10/2016 10:00:00 and one more with the day and some more with some other stuff.

    I need to find a formula that calculates how much time falls into a certain criteria.

    anyone ??

  2. #2
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    Welcome to the forum.
    Please upload a sample file. Don't include any confidential information, but do show the data you have to input and the result(s) you want - give an example calculated manually if possible. We need to know exactly what criteria you need to include in the calculation - so far you've mentioned a base salary (presumably per hour), Sunday bonus and night bonus - are there any others, for example? Are these bonuses fixed amounts or percentages? Once we can see this, we can try to work out a formula for you.

    To upload a file, click 'Go Advanced' then scroll down to 'Manage Attachments' and upload from there.
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  3. #3
    Registered User
    Join Date
    10-04-2016
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    4

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    Let me start by saying thank you so much for even looking at this.

    I have made up some dates next week which are representative for a typical week.
    On Sunday the 15th for example I’ll start at 8:30 p.m. and finish Saturday morning at 7:15 a.m.
    That means the following, three and a half hours will be Saturday, so I’ll will be getting “Saturday night work bonus” which is from 2 p.m. until midnight.

    from the start of Sunday morning until the end of my shift I will receive "Sunday work bonus", and additionally I will also receive “nights bonus” for 6 hours that day, because it is applicable from midnight until 6 a.m. any night of the week.

    So on a Saturday night shift i'll get pay and 3 different bonus pays, and on a Thursday i work the same amount of hours but get €30 less because it's midweek and midday.

    I don't know if it is possible to build a formula that can calculate this.

    I am really grateful that you are looking at this, thanks.
    Attached Files Attached Files
    Last edited by CreoDk; 10-05-2016 at 04:58 AM. Reason: missing upload

  4. #4
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    It's certainly possible, but the formulae will be a bit complicated as they'll need to check various combinations of day of week, start time, end time and so on. A single formula will probably end up being huge and difficult to understand (or amend if necessary), so it might be best to have a few helper columns to do intermediate calculations which can then be combined - they can be hidden so you just see the final results.
    I'll look at this over the next couple of days and get back to you - sorry it won't be quicker but I've got a few other things going on just now (family and work).

    Edit:
    A question - is there a maximum number of hours you will work at a time?
    What I'm wondering is, could you start work at 05:30 one morning and finish at 00:30 the next day, for example, or start at 23:00 on Fri evening and work to 15:00 on Sat?
    If this is possible, then I need to make sure the formulae account for all possible combinations across your various bonus periods. If you would never work more than 12 hours, or 15 hours, or whatever, then I can disregard those combinations.
    Hope that makes sense!
    Last edited by Aardigspook; 10-05-2016 at 04:16 PM. Reason: Add question

  5. #5
    Registered User
    Join Date
    10-04-2016
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    4

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    Take all the time you need

    The maximum is 14 hours, so far.
    Some times we do 12 hours, so from 19:00 to 07:00, or from 07:00 to 19:00, but starting at 06:00 is the most early that i see done.

    It sound really extensive, i am so happy that you take this on.

  6. #6
    Registered User
    Join Date
    10-04-2016
    Location
    Denmark
    MS-Off Ver
    365
    Posts
    4

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    Take all the time you need

    The maximum is 14 hours, so far.
    Some times we do 12 hours, so from 19:00 to 07:00, or from 07:00 to 19:00, but starting at 06:00 is the most early that i see done.

    It sound really extensive, i am so happy that you take this on.

  7. #7
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    Just to let you know I haven't forgotten about this. Unfortunately I've been very busy the last couple of weeks (helping my wife's parents move house, among other things) but I'm hoping to have this finished in the next couple of days. Currently it involves a few helper columns which I'm hoping to reduce a bit, though there will still probably be a few, just to make it understandable!

  8. #8
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: I need to find a formula that calculates how much time falls into a certain criteria.

    Firstly, apologies for the long post coming up, but I think this needs some explanation, just in case you want to change anything in the future.

    Summary
    See attached file, which has three different options for you, depending on how much detail you want to see - look at the sheets AS1, AS2 and AS3 for the options.

    Full Explanation

    The attached file has 5 worksheets.
    1. The first (Ark1) is your original - with a correction to the Total Pay Sum.
    2. The second (PayRates) is a copy of your time periods and rates of pay for those periods. I separated these out on to a different sheet for ease of making 'Names' - which will become clear later.
    3. The third (AS1), fourth (AS2) and fifth (AS3) all give the final result you want - the Total Pay - but with different levels of visibility of what's going on. More details later.

    On each of the AS1/2/3 sheets, I've put in some additional rows to show examples of the different time periods being worked out.


    Before I go into the details of formulae, let's cover the 'Names'.
    'Names' (or 'Named Ranges') are used in Excel to represent references, values or formulae with a name, rather than typing them every time (see here for details: https://support.office.com/en-gb/art...2-ABD7FF379C64).
    I've defined 11 Names - each starts with NR_ to indicate that it's a Named Range. 6 of them are the time periods for each rate of pay and 5 are the pay rates for those periods:
    Please Login or Register  to view this content.
    So, for example, if a formula needs to check if a time is later than 18:00, it checks if the time is > NR_MFEveStart.
    You can change the names by clicking 'Name Manager' on the 'Formulas' tab (sorry, I don't know what they're called in Danish!). Click 'Edit' to change the name title or reference. If you change the name title, you'll need to do a 'Find and Replace' for all references to it in the formulae on the other sheets.

    Now let's look at the other sheets and formulae which calculate the time periods and pay.

    First sheet: AS1, which shows the hours worked in each time period, the pay for each period and the total pay (a simple sum of the previous columns).

    The formulae to calculate the hours for each time period are below. Each starts with a check to see that there's both a start date/time and an end date/time - if not, a blank is returned (that's the IF(OR(C4="",D4=""),"", part).
    Start and end times are calculated by using MOD on the date/time in columns C and D. Days of the week are checked by using WEEKDAY - if it's just to check that the start and end days are the same, then just WEEKDAY() is used - if it's to check the actual day of the week, WEEKDAY(ref,1)=1/2/3/4/5/6/7 is used (1=Sunday, 7=Saturday).


    The Total hours formula is a simple subtraction of start date/time from end date/time:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The formula to calculate evening hours Mon-Fri ('M-F eve hours') is substantially longer. It variously checks the weekdays of the start and end dates, then checks the start and end times to work out how much of the time worked falls within the 1800-2400 period on Mondays to Fridays:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The formula for hours on Sat afternoon/evening is shorter, checking for hours worked which fall between 14:00 and 24:00 on Saturday:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The formula for night hours does the same sort of thing, checking for hours worked between 00:00 and 06:00, though it doesn't need to check for the day of the week, as this applies every day::
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The Sunday hours formula is a lot shorter, just checking for hours worked on Sundays:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    The amount of pay for each period is then calculated by converting the time to decimal and multiplying by the rate of pay:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    The total pay is then just a sum of the above:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Second sheet: AS2, which shows the pay for each period and the total pay - the hours worked in each period aren't shown - the formula calculating the pay for each period has the calculation of hours embedded in it. Essentially, it takes the formulae from sheet AS1 listed above for time-worked and combines those with the formulae for amount of pay.

    Base pay stays much the same:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Mon-Fri evening pay:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Sat afternoon/evening pay:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Night pay:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Sunday pay:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Total pay is again a sum of the other columns:
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Third sheet: AS3, which shows only the total pay due - the hours worked and pay for each period aren't shown - the final formula does all of it in one:
    Formula: copy to clipboard
    Please Login or Register  to view this content.




    Last Notes


    All the formulae above (on all the sheets) should work for shifts up to 24 hours. They may work for longer periods, but I've only tested up to 24 hours.


    Finally, please note that all of the formulae above use commas (,) as separators. Your settings may use semi-colons (;) instead. Obviously, the formulae are also in English. However, if you look at the attached file in Danish, then Excel will automatically convert the formulae - both words and commas.

    Sorry it's taken so long, but I hope this does what you need. If you find something not working, or you'd like to change something but don't know how, then just let me know.

+ 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. Excel Formula that calculates hours worked between a set time
    By Ixorian in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-24-2015, 02:27 PM
  2. [SOLVED] Modify Formula that Calculates Time
    By Karen615 in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 06-11-2014, 03:26 PM
  3. Need formula that calculates AVG number based on exact criteria
    By Lindee in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-14-2014, 03:17 PM
  4. find min dates calculates aging from AJ column with determined formula
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2013, 11:56 AM
  5. [SOLVED] Find row where time value falls between start and end time values
    By wraithlet in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-12-2013, 12:35 PM
  6. Need Help to get a formula that calculates my total shift time pls
    By becksmaster in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-04-2013, 12:20 AM
  7. Replies: 1
    Last Post: 03-11-2010, 09:12 AM

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