+ Reply to Thread
Results 1 to 8 of 8

Time calculation formula

  1. #1
    Registered User
    Join Date
    02-29-2024
    Location
    Hrvatska
    MS-Off Ver
    365
    Posts
    3

    Time calculation formula

    Hello,

    i need help with time calculation.

    I have 2 sheets. First contains 4 rows with data about date, day, shift time, and shift end. (Mon-Fri 06-22 and Sat 06-14, Sun is free day). Starting date is 01.01.2024.
    Second sheet has 3 rows, first is the name of the operation. second is date and time of start (ex. 01.01.2024. 06:00), and third is lenght of operation.

    I need formula to put in cell B3 in sheet 2 which would calculate date and time for start of second operation based on date and time of first operation + lenght of first operation, but it should take in consideration data from sheet 1 (shift lenghts and nonworking days).


    Thank you in advance.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,730

    Re: Time calculation formula

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. The sample layout accurately matches that of your real data. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    02-29-2024
    Location
    Hrvatska
    MS-Off Ver
    365
    Posts
    3

    Re: Time calculation formula

    I attached an example. Thank you again.
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,706

    Re: Time calculation formula

    Perhaps this inelegant solution will help until someone using the functions supported in the 365 version of Excel can maybe accomplish this more efficiently.
    1. Copy transpose the data from Sheet 1 to the top of sheet 2.
    2. Add a row for duration populated using: =IFERROR((E3-E2)*24,0)
    3. Populate a calculation matrix (green) using: =IF(OR(E$2="closed",SUM(E$5:E5)=E$4),"",MIN($C6-SUM($D6:D6),E$4-SUM(E$5:E5)))
    4. Start dates/times (blue) are calculated using: =SUM(INDEX(E$1:R$1,MATCH(0,E6:R6,0)-1),INDEX(E$2:R$2,MATCH(0,E6:R6,0)-1),SUMPRODUCT(INDEX($E$6:R6,,MATCH(0,E6:R6,0)-1))/24)
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Time calculation formula

    Just another function.

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


    Excel 365 (Windows) 64 bit
    I
    J
    K
    L
    M
    1
    Operation Start Lenght (in hours)
    2
    1
    1/1/24/ 6:00
    36
    3
    3/1/24/ 10:00
    2
    3/1/24/ 10:00
    85
    4
    10/1/24/ 7:00
    3
    10/1/24/ 7:00
    13
    5
    10/1/24/ 8:00
    4
    10/1/24/ 20:00
    21
    6
    11/1/24/ 13:00
    5
    13/1/24/ 1:00
    Sheet: Sheet 1

    There is a divergence of results in the third row that I think is clear that adding 7 plus 13 goes to 20, the last result is a consequence of the third one.
    Attached Files Attached Files
    Last edited by DJunqueira; 03-03-2024 at 04:28 PM.

  6. #6
    Registered User
    Join Date
    03-03-2024
    Location
    United States
    MS-Off Ver
    Office 365
    Posts
    5

    Re: Time calculation formula

    I currently have a formula below that works for calculating the monthly salary based on start and end date. Here it is....

    IF(OR($B2>EOMONTH(E$1,0),$C2<E$1),"",$D2*(MIN(EOMONTH(E$1,0),$C2)-MAX(E$1,$B2)+1)/IF(MOD(YEAR($E$1),4)=0,366,365))


    This calculates the monthly salary based on the number of days in the month compared to the annual salary. As a result, each monthly salary is different based on the number of days.

    I would like to change this formula so that the monthly salary is the same each month except for partial months (either the start date month or the end date month). In this case, the prorated salary for the month that has a partial date should calculate based on the # of days in month as a % of total days in that month.

    For example, a person with annual salary of $120,000 has a monthly salary of $10,000. If the person is starting on May 15, 2024, the salary cost for the month of May is $5,484. From May 15th through May 31st is 17 days, so the cost is equal to 17*(10,000/31). I would then want to see a monthly salary cost of $10,000 from June onwards until the person leaves. The month they leave would be prorated similarly.

    Can anyone help with this update to the above formula? Thanks!

  7. #7
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: Time calculation formula

    Welcome to the forum IPOK,
    but I think you will need to create another tread.

  8. #8
    Registered User
    Join Date
    02-29-2024
    Location
    Hrvatska
    MS-Off Ver
    365
    Posts
    3

    Re: Time calculation formula

    Quote Originally Posted by DJunqueira View Post
    Just another function.

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


    ...

    There is a divergence of results in the third row that I think is clear that adding 7 plus 13 goes to 20, the last result is a consequence of the third one.

    Thank you for your formula, first 3 calculations seems perfect, but the last one sets time for next operation to 13/1/24 1:00 which isnt working time, it should instead be 12/01/24 09:00.
    Is there a way to fix this?

    Thanks in advance.

+ 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. Time calculation formula to VBA
    By pjbassdc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2016, 11:23 AM
  2. Over time calculation formula
    By Nawwy in forum Excel General
    Replies: 3
    Last Post: 08-02-2014, 03:27 PM
  3. [SOLVED] VB vs Formula - Calculation time
    By pytheus in forum Excel General
    Replies: 2
    Last Post: 06-26-2014, 04:19 AM
  4. Time calculation formula
    By mahesh8498 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-25-2012, 05:14 AM
  5. Excel 2007 : Formula help... Time calculation
    By artsim84 in forum Excel General
    Replies: 2
    Last Post: 10-21-2011, 01:18 PM
  6. Time Calculation Formula
    By smartcard in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2011, 09:59 AM
  7. Time Calculation Formula!
    By Mike in forum Excel General
    Replies: 5
    Last Post: 07-23-2005, 12:05 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