+ Reply to Thread
Results 1 to 11 of 11

Converting Text to Date - delimited format ?

  1. #1
    Registered User
    Join Date
    11-18-2003
    Posts
    33

    Converting Text to Date - delimited format ?

    I have two columns of dates in the following format :

    month/day/year

    The months and days are not fixed width, they are delimited by the slash only. For example :

    1/2/1999
    12/12/1999

    are both dates in my database. These fields are text, not date values. When I try to reformat the column as a date, the cells remain text and no operations (such as sorting) can be carried out.

    Is there a way of using formulas to convert the dates to actual date values, or must I use Vb ?

    Thanks

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    Did you try format the column to dates ??

    If you need a formula try this in B1 and drag down

    =DATE(YEAR(A1),MONTH(A1),DAY(A1))



    Then format cell as mm/dd/yyyy and copy and paste special values

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    11-18-2003
    Posts
    33
    Hmm talk about RTFH ! I found the 'FIND' formula......

  4. #4
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by Blewyn
    Hmm talk about RTFH ! I found the 'FIND' formula......
    Hi,

    =DATE(RIGHT(A1,4),SUBSTITUTE(IF(LEFT(RIGHT(A1,7),1)="/",LEFT(RIGHT(A1,6),2),LEFT(RIGHT(A1,7),2)),"/",""),LEFT(A1,FIND("/",A1)-1))

    would do all combinations for you

    hth

    amended
    ---
    Last edited by Bryan Hessey; 12-23-2006 at 04:28 AM.
    Si fractum non sit, noli id reficere.

  5. #5
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Enter "1" in a cell. Copy the content of this cell.
    Select the range of dates you want to change and select Paste Speclal - Multiply - OK.
    All the cells will be converted to dates , you must then format as you wish.

  6. #6
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Quote Originally Posted by arthurbr
    Enter "1" in a cell. Copy the content of this cell.
    Select the range of dates you want to change and select Paste Speclal - Multiply - OK.
    All the cells will be converted to dates , you must then format as you wish.
    That method doesn't work if the text date is say 10/21/1999
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  7. #7
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by oldchippy
    That method doesn't work if the text date is say 10/21/1999
    I don't like to trust Excel with dates, I prefer to specify whereever possible, especially considering the mess it makes of trying to export to csv a non-US format date.

    ---

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Quote Originally Posted by Blewyn
    Is there a way of using formulas to convert the dates to actual date values, or must I use Vb ?
    You can covert in situ without formulas or VB

    Select the column of dates

    Data > text to columns > Next > Next

    At step 3 select "Date" from "Column data format" and "MDY" from dropdown

    Finish

  9. #9
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by daddylonglegs
    You can covert in situ without formulas or VB

    Select the column of dates

    Data > text to columns > Next > Next

    At step 3 select "Date" from "Column data format" and "MDY" from dropdown

    Finish
    Yes, but that was after Excel '97 (for those still using that)

    In '97 the format was taken from the first date in the column.

    hth
    ---

  10. #10
    Registered User
    Join Date
    11-18-2003
    Posts
    33
    I did it by using TEXT to convert all dates to text (I had a mixture of date and text fields in the same column), then "Text to Columns" to separate out the values for day, month and year,then used DATE(Year,Month,Day) to convert back to a proper date value.

    Thanks to all for your advice, and Merry Christmas !

  11. #11
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Blewyn,

    Glad you got an answer.

    Merry Xmas

    VBA Noob

+ 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