+ Reply to Thread
Results 1 to 7 of 7

Converting decimal into time

  1. #1
    Registered User
    Join Date
    01-17-2023
    Location
    Seattle, WA
    MS-Off Ver
    Excel for Microsoft 365 MSO (Version 2212 Build 16.0.15928.20196)
    Posts
    4

    Converting decimal into time

    Greetings all, this is my first post in here.

    I'm struggling with maintaining integrity of some data. I export from Global Shop Crystal Report Viewer into Excel. Unfortunately, I run into a problem right off the bat. What should be kept as time, turns into a decimal (example, hh:mm, can range from 00:01 to 25:31 or more; these values turn into 0.01 and 25.31, rather than maintaining the colon. The numbers/digits are correct; it just loses the colon. Of course, find/replace doesn't work!).

    This was solved for a while, with an answer from MyOonlineTrainingHub. (You'll see in the attached file I was using INT and MOD with arithmetic to convert.) Recently, I noticed it hiccupping more frequently. In the file, rows 4, 10, and 14 are examples of how things should be. Looking at columns H, I, K and L. For instance, in row 10, 7.20 converts to 7:20, and 3.25 to 3:25. This is how it all should be! Keep the numbers, just get that decimal into a colon and format with [h]:mm

    I've double checked things too many times now, if you know what I mean Had me stumped yesterday. Does anyone know a better solution than the INT and MOD stuff I have going on in there? For all I know, there's something staring me right in the face.

    Note: I have about 200,000 rows of data of this stuff. I also have occasional negative time values (that should remain negative).

    Thank you in advance!
    Attached Files Attached Files

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Converting decimal into time

    Try this in K2:

    =SUBSTITUTE(TEXT(H2,"0.00"),".",":")+0

    Format as Custom [h]:mm and then drag to the right and down.

  3. #3
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Converting decimal into time

    As for the negative values part, you can't have negative times.

    You can display all of the values as text by removing the +0 at the end of the formula from post #2, and the negative would stay, but note that the cells will then be text values and not numbers/times.

  4. #4
    Registered User
    Join Date
    01-17-2023
    Location
    Seattle, WA
    MS-Off Ver
    Excel for Microsoft 365 MSO (Version 2212 Build 16.0.15928.20196)
    Posts
    4

    Re: Converting decimal into time

    Well shoot....that didn't quite work for me. Looked very hopeful at first! I think it works for more of the cells now than before.

    What's super puzzling right now is that it seems to work just fine for some cells. But others, it's returning a completely different value. (see highlighted examples, yellow=wrong, green=correct)

    Attachment 813779

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Converting decimal into time

    Your attachment from post #4 is invalid. I cannot see it.

    Putting the formula from post #2 into the workbook from post #1, essentially replaces the "." from columns H and I with ":" and converts them to time values.

    For instances like cell H6 where you have 15.60, what time value should this be?
    15:60 is not a valid time, which is why the formula converts this to 16:00.

    I assume this is what you are referring to. What would you like for to show instead here?
    15:60 (as a text value), 15:36 as a time value (since 0.6 hours = 36 mins), or something else?

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,819

    Re: Converting decimal into time

    I don't know if this is better than your current formula, but I did =TIME(LEFT(TEXT(abs(H2),"000.00"),3),RIGHT(TEXT(abs(H2),"000.00"),2),0)*sign(H2) formatted as elapsed hours [hh]:mm and that works just fine. If you are not limited to Excel only, other spreadsheets (like Google Sheets and LO Calc) have no trouble displaying negative times, so this formula should work as is in other spreadsheets. As 63falcondude notes, if you are limited to Excel, then you will be required to store your times as text strings.

    I also notice that the discussion is focused on "fixing" the problem after the data are imported into Excel. I think it is often better to "fix" this problem before the data are imported or during the import step. You haven't shared anything about the process of going between the viewer app and Excel. We probably can't help much with the "export form the viewer" step, but we may have some ideas for the "import into Excel" step that may help avoid this whole situation.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  7. #7
    Registered User
    Join Date
    01-17-2023
    Location
    Seattle, WA
    MS-Off Ver
    Excel for Microsoft 365 MSO (Version 2212 Build 16.0.15928.20196)
    Posts
    4

    Re: Converting decimal into time

    Got into work this morning & followed technology 101: start over & do a fresh re-export of data. I used the original formulas (INT, MOD, etc) with format [h]:mm. Then I spent 10 minutes simply looking at and comparing numbers.

    Of course, it looks like everything is back to the way it should be!

    My only guess is data got corrupted somewhere along the way. Maybe during a copy/paste.

    Okay to disregard at this point! (Looking for a place to mark this as resolved. Is that a thing on this forum?)

+ 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] Converting an elapsed time in decimal number format to an actual time :S
    By Spicey_888 in forum Excel General
    Replies: 3
    Last Post: 07-20-2014, 08:53 PM
  2. Converting military time to decimal time not rounding correctly
    By Sean Anderson in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-23-2008, 09:12 PM
  3. [SOLVED] Converting time to decimal
    By Dawnyanne in forum Excel General
    Replies: 2
    Last Post: 05-24-2006, 01:00 PM
  4. Converting decimal to time
    By Charlene in forum Excel General
    Replies: 13
    Last Post: 04-13-2006, 04:00 AM
  5. Converting Decimal to Time
    By Charlene in forum Excel General
    Replies: 7
    Last Post: 04-11-2006, 05:30 PM
  6. Converting a Decimal Value to a Time Value
    By An Irish Airman in forum Tips and Tutorials
    Replies: 1
    Last Post: 08-23-2005, 12:09 PM

Tags for this Thread

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