+ Reply to Thread
Results 1 to 8 of 8

Converting text to date

Hybrid View

  1. #1
    Registered User
    Join Date
    09-25-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    Converting text to date

    Hi, I have imported data that is showing dates as 18th Sep 2013. Excel does not like this and I have tried various methods of conversion but nothing seems to work. I will be getting data that has Oct, Nov, Dec etc so the formula needs to be able to handle these too. I would like these 'dates' converted to excel friendly dates. Can any one help please?

    Thanks,

    Ros

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,852

    Re: Converting text to date

    Can you submit a sample workbook (the FAQ describes how to), so we can see the variations you are likely to encounter.

    Pete

  3. #3
    Registered User
    Join Date
    09-25-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Converting text to date

    Hi thanks for the quick reply! Wookbook attached.
    Attached Files Attached Files

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,852

    Re: Converting text to date

    Well, if that's all you are going to get then you could do this in B1:

    =DATEVALUE(SUBSTITUTE(A1,"th",""))

    and copy down.

    But, I suspect you will also have 1st, 2nd, 3rd, 21st, 22nd, 23rd in among those dates, so you need to remove the other ordinal initials. Is that the case?

    Pete

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Converting text to date

    This will work for part of the problem (A1 and A2 but not A3) or for other numeric endings such as st rd nd etc.

    =SUBSTITUTE(SUBSTITUTE(A1,"th ","/")," ","/")*1

    The DATEVALUE formula may serve your purposes better.
    Attached Files Attached Files
    Last edited by newdoverman; 09-25-2013 at 12:10 PM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,852

    Re: Converting text to date

    If you want a more universal formula, put this in B1:

    =IF(A1="","",DATEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"th "," "),"st "," "),"nd "," "),"rd "," ")))

    then copy down as far as you like.

    Hope this helps.

    Pete

    EDIT: this will only give you the date - it will remove any time element you might have in there (like your 3rd example).

    Also, you should format the cells as dd/mm/yyyy.

    Pete
    Last edited by Pete_UK; 09-25-2013 at 12:15 PM.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Converting text to date

    This will take care of "th, nd and rd"

    =DATEVALUE(SUBSTITUTE(A1,MID(A1,SEARCH(" ",A1)-2,3)," "))
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Converting text to date

    To have the time as well as the date insert a helper column and use the Text to columns feature on the Data tab to split the hours and minutes into column B. In column C enter this formula to reassemble the data as a date. (format as dd/mmm/yyyy h:mm)

    =DATEVALUE(SUBSTITUTE(A1,MID(A1,FIND(" ",A1,1)-2,2)," "))+B1

    This is pretty much a combination of previous suggestions with the addition to get the hours and minutes.
    Last edited by newdoverman; 09-25-2013 at 04:19 PM.

+ 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. Converting text string that contains a date and time to a date
    By jmforde in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2013, 02:31 PM
  2. Replies: 0
    Last Post: 01-30-2013, 07:05 PM
  3. [SOLVED] Converting from Text>Date Serial>Date
    By Schwartz in forum Excel General
    Replies: 17
    Last Post: 04-17-2012, 04:26 PM
  4. Converting Text Date to Actual Date using VBA
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2010, 12:20 PM
  5. Converting date text to date format
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2009, 06:10 AM

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