+ Reply to Thread
Results 1 to 14 of 14

How to totalise time formatted cells

  1. #1
    Registered User
    Join Date
    09-16-2011
    Location
    Djupivogur, Iceland
    MS-Off Ver
    Excel 2007
    Posts
    33

    How to totalise time formatted cells

    I know the title is stupid...
    I am making a timesheet for my employees. On the sheet I have to put in when the arrive and when they quit. I have the time format 00:00 on the cells.

    For ex. one arrives at 08:00 (cell A1) and leaves at 15:45 (cell A2).
    What formula do I put in A3 so the outcome will be 7,75 hours?
    Last edited by olafurbj; 09-16-2011 at 10:22 AM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: How to totalise time formatted cells

    This should work for you =TEXT((A2-A1)*24,"##.##")

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: How to totalise time formatted cells

    HTML Code: 

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: How to totalise time formatted cells

    Note that Andrew-R's solution will give you a text output rather than numeric so may present problems if you want to do further arithmetic with it.


    Regards

  5. #5
    Registered User
    Join Date
    09-16-2011
    Location
    Djupivogur, Iceland
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: How to totalise time formatted cells

    Andrew's formula worked for me, I added two dashes more to get the two decimal places to make it accurate.

    =TEXT((A2-A1)*24,"##.##,##")

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: How to totalise time formatted cells

    Do you want a TEXT return?

    =(A2-A1)*24 will produce a simple numeric value, 7.75 in this case.

    Regards

  7. #7
    Registered User
    Join Date
    09-16-2011
    Location
    Djupivogur, Iceland
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: How to totalise time formatted cells

    When I look better into it you're right TMShucks.
    Your solution works better for me. Thank you.

  8. #8
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: How to totalise time formatted cells

    <Super-villain>You win this round, TMShucks, but I'll be back!</S-V>

  9. #9
    Registered User
    Join Date
    09-16-2011
    Location
    Djupivogur, Iceland
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: How to totalise time formatted cells

    Ok, Andrew-R, try to solve this problem for me :

    I've got this formula that calculates overtime for me. Overtime is past 16:00. This is the formula I put together and it works fine, except when an employee does not work all the way to 16:00, for ex. 15:45

    =IF(D6>"16:00";0;(D6-"16:00")*24)

    If an employee works from 08:00 till 16:45, the formula delivers 0,75 overtime hours.
    BUT, if an employee works from 08:00 until 15:45, the formula delivers -0,25.

    What do I add to the formula so the total doesn't go below 0 ?

  10. #10
    Forum Contributor
    Join Date
    08-04-2008
    Location
    West Calder, Scotland
    MS-Off Ver
    365
    Posts
    418

    Re: How to totalise time formatted cells

    Hi olafurbj

    Try this, Put 16:00 in another cell, e.g C6 and lock the equation to that cell $C$6,,, when you copy the equation to other cells it will continue to look at C6

    =IF(D6>$C$6,D6-$C$6,0)*24

    JT
    Last edited by JamesT1; 09-16-2011 at 12:16 PM.

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: How to totalise time formatted cells

    I'd be inclined to use TIME rather than a text value ... and I think you have the outcomes the wrong way around. Try:

    =IF(D6>TIME(16,0,0),(D6-TIME(16,0,0))*24,0)

    though you may need to change the commas to semi-colons.

    Regards

  12. #12
    Registered User
    Join Date
    09-16-2011
    Location
    Djupivogur, Iceland
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: How to totalise time formatted cells

    TMShucks, this is how I should put your formula into the Function Arguments column?:

    IF
    Logical_test D7>TIME(16;0;0)
    Value_if_true D7-TIME(16;0;0)*24
    Value_if_fase 0

    If an employee works until 16:45 this formula delivers -15,30208333.
    What am I doing wrong?

  13. #13
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,299

    Re: How to totalise time formatted cells

    I think:

    Logical_test D7>TIME(16;0;0)
    Value_if_true (D7-TIME(16;0;0))*24
    Value_if_fase 0

    D7 is a time; TIME(16;0;0) is a time; so (D7-TIME(16;0;0)) is a time; (D7-TIME(16;0;0))*24 is a number.

    Regards

  14. #14
    Registered User
    Join Date
    09-16-2011
    Location
    Djupivogur, Iceland
    MS-Off Ver
    Excel 2007
    Posts
    33

    Re: How to totalise time formatted cells

    Quote Originally Posted by TMShucks View Post
    I think:

    Logical_test D7>TIME(16;0;0)
    Value_if_true (D7-TIME(16;0;0))*24
    Value_if_fase 0

    D7 is a time; TIME(16;0;0) is a time; so (D7-TIME(16;0;0)) is a time; (D7-TIME(16;0;0))*24 is a number.

    Regards
    GENIUS.
    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