+ Reply to Thread
Results 1 to 3 of 3

CSV Import is incorrectly converting when there are 5 chars instead of 7 (hh:mm:ss)

  1. #1
    Registered User
    Join Date
    11-24-2018
    Location
    London, UK
    MS-Off Ver
    Excel for Mac
    Posts
    1

    CSV Import is incorrectly converting when there are 5 chars instead of 7 (hh:mm:ss)

    If I open a csv file with the following duration data

    30:00
    45:00
    1:00:00
    1:30:00

    The top numbers are incorrectly being converted to:
    30:00:00
    45:00:00
    1:00:00
    1:30:00

    So zeroes are being added to the right instead of the left, changing the values. I have tried Importing and changing that column to text but it wrecks the rest of the data.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: CSV Import is incorrectly converting when there are 5 chars instead of 7 (hh:mm:ss)

    Attach a sample .csv file that represents your actual file. Without actually seeing your data, it is difficult to determine what is happening and why.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: CSV Import is incorrectly converting when there are 5 chars instead of 7 (hh:mm:ss)

    There is no way for Excel to know for sure whether 30:00 means 30 hours or 30 minutes. What Excel assumes is:
    - Values from 00:01 through 23:59 are displayed and interpreted as hh:mm
    - Values from 24:00 through 59:59 are displayed and interpreted as hh:mm:00.

    Once the import of the CSV has been completed the information needed to "fix" Excel's assumption is lost. The only practical way I can see to achieve the madmel1984's intent is as follows: (steps are for Excel 2010, other versions may work a little differently)

    1) Open a new workbook or an existing workbook into which you wish to import the data.

    2) From the Data tab on the ribbon select "Get External Data" then select "From Text". Navigate to your CSV file and click "Import"

    3) Within the wizard, accept the defaults for steps 1 and 2. At step 3 change the Column data format from "General" to "Text" then click "Finish".

    4) Excel asks "Where do you want to put the data". Choose a location. I assume A1 for the remaining steps.

    5) At this point you have a text-formatted column-A looking exactly like the the original CSV file.

    6) Apply an appropriate date format to column-B (one that shows hours AND minutes AND seconds!)

    7) Apply the following formula to B1 and copy down. This gives you proper dates aligned with your expected values in column-B.

    =IF(LEN(A1)<7, TIMEVALUE("0:"&A1), TIMEVALUE(A1))

    8) If necessary copy column-B and paste-values then delete column-A.

+ 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] How Do I Stop A Text File Import From Converting to a Date?
    By jayclinton in forum Excel General
    Replies: 2
    Last Post: 05-04-2017, 01:59 PM
  2. Converting a Timesheet To a csv import file
    By Bec Connolly in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-02-2015, 12:44 AM
  3. [SOLVED] Macro converting time incorrectly
    By Hyflex in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-18-2011, 07:58 PM
  4. Date Converting Incorrectly HELP!
    By mlong219 in forum Excel General
    Replies: 11
    Last Post: 11-07-2006, 01:53 PM
  5. UDF Can't return more than 255 chars???
    By R Avery in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2006, 04:10 PM
  6. Replies: 2
    Last Post: 03-16-2006, 11:15 AM
  7. [SOLVED] Removing last three chars
    By teresa in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-23-2005, 09:06 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