+ Reply to Thread
Results 1 to 9 of 9

Summing [h]:mm:ss and/or converting to total seconds

  1. #1
    Registered User
    Join Date
    06-16-2009
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Lightbulb Summing [h]:mm:ss and/or converting to total seconds

    All,

    I am in need of some help with some time-format stuff.

    I am trying to calculate some long-distance costs, and we get billed by the second.

    What I have is a call detail report that contains the durations of every single call we've made. In my column J, I have those lengths, with custom formatting of [h]:mm:ss:

    J
    :12:19
    :02:21
    48:00:26
    :13:02
    :37:02
    :01:34
    :41:55

    The fact that Excel is now showing a zero for those calls that lasted less than one hour is killing me and I can't figure out how to get it in there.

    In the grand scheme of things, I need to convert each of these times to total seconds for each call. On some websites help, I have tried using '=HOUR(J2)*3600+MINUTE(J2)*60+SECOND(J2) to no avail. Cell J2 would be the one above containing 02:21, but since there is nothing present for the number of hours, it bombs as a bad value.

    Interesting enough, if I continue on down and run that formula on J3 which contains an hours value, (48:00:26), it does do a calculation, but I've no idea how it came up with what it does....it comes back with 2246400. If you do the math on a calculator, (48*3600)+(0*60)+26, you'll get 172826 seconds, which is correct.

    Any ideas for how I can get those call durations converted to seconds for each call?

    Thanks in advance!

  2. #2
    Registered User
    Join Date
    08-06-2008
    Location
    Mumbai
    Posts
    2

    Re: Summing [h]:mm:ss and/or converting to total seconds

    Hi,

    You need to convert the hr format into decimal format for any summing. For this you need to multiply the number with 1440 (to convert into seconds format).

    For e.g :- 48:00:00 would be shown as 2880.0 (this is down to seconds level) in decimal format.

    Steps to follow:

    1. Add all your time format numbers in one coloum e.g A1, A2, A3 and so on
    2. In the coloumn next to this use the following formula "=A1*1440" (without the quotes)
    3. Drag this formula till all the data that needs to be converted is cleared.
    4. Select the entire B coloumn and convert the cell formatting to number. (format Cells --> number formatting).

    This will give you the correct decimal answer. i.e 48:00:00 will show as 2880.00 and time in seconds like 0:0:45 will show as 0.75

    This will help. Now to convert back to time format - instead of multiply use division.

    I have added a sample excel file for your better understanding.
    Hope this helps.

    Kailash
    Attached Files Attached Files
    Last edited by kailashnj; 06-16-2009 at 09:45 AM.

  3. #3
    Registered User
    Join Date
    06-16-2009
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Summing [h]:mm:ss and/or converting to total seconds

    Thanks for the reply. It worked for the column that had 48 hours, but not for the others, similar to what I've been experiencing before - it can't handle the missing value in the hours, and can't just assume it's zero:

    J is my original data, K is =J2*1440

    Column J Column K
    :12:19 #VALUE!
    :02:21 #VALUE!
    48:00:26 2880.433333
    :13:02 #VALUE!
    :37:02 #VALUE!
    :01:34 #VALUE!

    Edit: Sorry for the lost formatting, hopefully you can ready this.
    Last edited by networkmd; 06-16-2009 at 09:54 AM. Reason: Formatting

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Summing [h]:mm:ss and/or converting to total seconds

    looks like the :00:30 are text so
    =IF(LEFT(A1,1)=":",TEXT("00"&A1,"hh:mm:ss"),A1)*86400
    dragged down will give seconds cells formatted general
    change a1 to j1 as required
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Summing [h]:mm:ss and/or converting to total seconds

    You can convert to seconds with this formula in K2 copied down

    =(0&J2)*86400

  6. #6
    Registered User
    Join Date
    06-16-2009
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Summing [h]:mm:ss and/or converting to total seconds

    I just saw the example you attached. So my real issue is those missing zeros. Any idea how to get them quickly added in, to about 25,000 rows of data? Adding them manually is out of the question.

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Summing [h]:mm:ss and/or converting to total seconds

    You don't have to alter the data, the formula can do that for you, see my suggestion above

  8. #8
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Summing [h]:mm:ss and/or converting to total seconds

    =(0&J2)*86400 lol i went for overkill!!

  9. #9
    Registered User
    Join Date
    06-16-2009
    Location
    Columbus, OH
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Summing [h]:mm:ss and/or converting to total seconds

    Quote Originally Posted by daddylonglegs View Post
    You can convert to seconds with this formula in K2 copied down

    =(0&J2)*86400
    That did the trick - it's working beautifully - 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