+ Reply to Thread
Results 1 to 6 of 6

Handling imported dates, some with a trailing space

  1. #1
    Registered User
    Join Date
    12-18-2011
    Location
    Leamington Spa, England
    MS-Off Ver
    Excel 2007
    Posts
    20

    Post Handling imported dates, some with a trailing space

    An external query of a web database returns names and dates, Col A & Col B on the attached work book. Some, but not all, of the dates have a trailing space. I want to convert the dates (which are in US format mm/dd/yyyy) to their Excel date-time code so that I can perform subsequent operations and format UK dd/mm/yyyy.
    I've browsed several possible solutions e.g. (TRIM) and Find/Replace which appear to remove the space(s) but the date then stubbornly refuses to convert to Excel date-time code. I've also tried the Web query with the option "Match Destination Formatting" (general) without success.

    Is there a solution which doesn't involve VBA?
    Attached Files Attached Files
    Last edited by JonnieB; 10-04-2012 at 08:45 AM.

  2. #2
    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
    48,454

    Re: Handling imported dates, some with a trailing space

    Use Data | Text to columns. First select the column of dates. Use space as a delimiter and specify that the column is a date in MDY format. Copy to another column for your safety. If they look OK, copy them over the originals.


    Regards, TMS
    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


  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,744

    Re: Handling imported dates, some with a trailing space

    Jonnie,
    I am not sure what the issue is that is causing this. In an attempt to examine the contents of the cells in question, I highlighted one and clicked on the F2 (edit) key and then the Enter key and immediately the number converted correctly. I tried this on several other cells and they all converted. Very manual exercise if you don't want to use VBA, but doable depending on how large your data table is. You may be better off with a quick macro to loop through the data if your data is very large.

    Alan
    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

  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: Handling imported dates, some with a trailing space

    text to columns will certainly fix it no need for an delimiter just select column use mdy click finish
    "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
    Registered User
    Join Date
    12-18-2011
    Location
    Leamington Spa, England
    MS-Off Ver
    Excel 2007
    Posts
    20

    Re: Handling imported dates, some with a trailing space

    Thanks to all, for the speedy responses. Text to columns (not something I would have thought of) with mdy works perfectly.
    I've checked the 'Add to reputation' for all.

  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
    48,454

    Re: Handling imported dates, some with a trailing space

    You're welcome. Thanks for the rep.

+ 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