+ Reply to Thread
Results 1 to 13 of 13

Time Calculations

  1. #1
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Time Calculations

    I have a spreadsheet that is showing times in a single column as 1h 23m 45s...

    Some of the entries have the h, some do not...

    Some of the entries have the m, some do not...

    Some have the s, some do not...

    Any way to clean this up with a text-to-column or formula style for mass data (over 2500 rows of data) - see attached
    Attached Files Attached Files

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,063

    Re: Time Calculations

    Exactly what format do you want Excel to return the data in??
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Time Calculations

    Oh sorry, guess I shoulda specified that! LOL I want just a total in either minutes or seconds. Normally I just run a text to column, then in a new blank column run a formula such as:

    =A3*60+B3*60+C3

    Then autofill...

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Time Calculations

    Compliments of daddylonglegs:

    Row\Col
    D
    E
    F
    2
    1h 06m 44s
    1:06:44
    E2: =SUM(MID(0 & D2 & "0000", SEARCH({"D","H","M","S"}, D2 & "xxDHMS")-1, 2) / {1,24,1440,86400})
    3
    21m 43s
    0:21:43
    4
    07m 58s
    0:07:58
    5
    00m 00s
    0:00:00
    6
    00m 00s
    0:00:00
    7
    00m 00s
    0:00:00
    8
    1h 42m 55s
    1:42:55
    9
    00m 00s
    0:00:00
    10
    1h 51m 11s
    1:51:11
    11
    31m 43s
    0:31:43
    12
    1h 48m 31s
    1:48:31
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Time Calculations

    I used the following format in Column H with a cell format of [hh]:mm:ss

    =IF(ISNUMBER(SEARCH("h",E2)),LEFT(E2,SEARCH("h",E2)-1)/24,0)+MID(E2,SEARCH("m",E2)-2,2)/(60*24)+MID(E2,SEARCH("s",E2)-2,2)/(60*60*24)
    Would this work for you?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Time Calculations

    And people at work sing my praises on Excel knowledge! I look at this formula and think "Holy s%^&!" LOL

    let me see if I can decipher this...the formula searches the cell E2 for variable "h", then takes the value immediately preceeding it and divides by 24?

    It then repeats that same logic for "m", except adds the function of multiplying by 60 in there...

    It then repeats that same logic for "s", except adds the function of multiplying by 60 a second time...

    Can I ask why the divisor by 24 in the results? Ideally I'd like just an X seconds number...

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Time Calculations

    If you are going to format your results as time, the Excel sees time as a subset of a day (makes sense) and uses the day as the primary unit. 1 in excel = 1 day. So when you are working with whole numbers but want them to be hours, 1 hour = 1/24 of a day so you divide by 24. 6 h = 0.25
    The same goes for minutes and seconds. Does that help?

  8. #8
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Time Calculations

    Yessir - thanks for the clarification...so if I wanted the result to be just seconds as a number (or minutes in a decimal value) so instead of 00:16:41 it'd just be 1001 seconds or 16.68?

    I guess I could just go and utilize text-to-columns at this point to split out with a : as the separator, then run the math...but it'd be handy if I could do that all in the formula...

    Last edited by CBJason; 12-30-2014 at 02:28 PM.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Time Calculations

    Once you've calculated it into the proper fraction of a day, then it's all up to how you want to format it. So let's say A1 contains 0.25

    If we go to cell format>custom and format as hh:mm we'll see 06:00
    if we format as h, we'll see 6
    if we format as mm, we'll see 01 (WELL, that's not right!) What Excel does with time is moves it into the proper positions. i.e. 60 minutes = 1 hour and 0 minutes, so we need to show all the units (format as dd:hh:mm:ss for example) or use [] to tell Excel that you want to top out at that unit.

    Soooo, back to the drawing board
    if we format as [mm], we'll see 360
    If A2 = 8.2 * A1, then
    if we format as hh:mm, we'll see 1:12 (because 6 hours * 8.2 = 2 days 1 hour 12 minutes)
    if we format as [hh]:mm, we'll see 49:12

    Make sense?

  10. #10
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Time Calculations

    Yep - I had that part, it was more a question of running the calculation within the IF search formula to sum up the h m and s parameters like (A2*60)*60)+(B2*60)+C2

  11. #11
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Time Calculations

    Any advice on how I can summarize these into a single value that would be usable in something like a pivot table (clients like the idle time to just be in minutes)...like 42.7 minutes

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Time Calculations

    To report everything as minutes, I would just convert everything to minutes.
    1 day = 24*60 minutes =1440
    so take the time * 14440 and format the cell as general.
    You could even do the calculations within the pivot table as a calculated field

  13. #13
    Registered User
    Join Date
    03-31-2013
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    33

    Re: Time Calculations

    That doesn't work because even with a custom setup as [mm]:ss the actual value in the field shows as a time value (with that ridiculous AM or PM in there that would then screw up any sort of text to column function. I've found a much easier way...

    Step 1: Got a character count using =len(A2) in a new column
    Step 2: Sorted the new column in decreasing order - so now all the cells with an hour value (say 1h 22m 15s) would be set at the top
    Step 3: Text to column with space as the delimiter
    Step 4: Find/Replace to remove the "h" "m" and "s" from the new resulting set of just that cell range
    Step 5: Add a new column and run a formula on the previous 3 columns i.e. E2*60+F2+G2/60 and I got the value I ultimately was looking for

    Funny how the fancy complicated formulas from earlier were taking me a longer time to try reformatting than this way...
    Last edited by CBJason; 01-22-2015 at 10:35 AM.

+ 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. [SOLVED] Extract a time from a cell with date and time stamp and then perform calculations
    By Marcos Aristotelous in forum Excel General
    Replies: 3
    Last Post: 10-31-2012, 04:36 AM
  2. date time calculations - elapsed time
    By jo3llen in forum Excel General
    Replies: 3
    Last Post: 07-11-2011, 01:43 PM
  3. Time Calculations:On-Time Performance
    By rmcquar in forum Excel General
    Replies: 1
    Last Post: 10-07-2010, 06:42 PM
  4. Time Calculations:length of time
    By KDaney in forum Excel General
    Replies: 1
    Last Post: 08-23-2010, 12:36 PM
  5. [SOLVED] convert time imported as text to time format for calculations
    By batfish in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-27-2005, 07:05 PM

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