+ Reply to Thread
Results 1 to 4 of 4

How can I extract a date from a string?

  1. #1
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    How can I extract a date from a string?

    Hi All,

    Is there a way to extract a date from within a string, when the format and position of the date is inconsistent?

    Examples of the dates in a full string are as follows (I've used 'Text' to identify a non date text string/word which can vary in number of characters, though to complicate further the number of words in the full string can also vary):

    Text 31-01-2017 Text Text Text
    Text 31/01/17 Text Text Text
    Text 31.01.17 Text Text Text
    Text 31/01/2017 Text Text Text Text
    Text Text Text Text 31-01-2017
    Text Text Text Text 31/01/17

    I can extract the date string & convert to a value if the position (whether by first/last character position or word number) is static or if the date followed a certain character (Using FIND), however this is not the case. Is there any function like "StringContainsADate" or any other way to achieve this?

    Thanks in advance

    Tooley

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: How can I extract a date from a string?

    All your date examples are ddmmyy
    Something to consider, could any of the dates be just dmmyy?
    Or even dmmyyyy or ddmmyyyy?
    Or are all dates in the ddmmyy?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,675

    Re: How can I extract a date from a string?

    Try this
    Please Login or Register  to view this content.
    Quang PT

  4. #4
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Re: How can I extract a date from a string?

    Hi Special K & Bebo,

    Special K,
    Unfortunately the data comes from a free text field input by the end user and I have no way of controlling how it's input.....Though have recommended a change in process so if any date is not input in an acceptable format, then any issues fall back on the user/team. In this case I'm please to inform that Bebo's suggestion does the trick. Thanks for getting back to me

    Bebo, Thanks hugely, I've tested about 2 dozen different combinations of date formats & position and so far has worked 100%.

    One point for other users, it's an array formula so you must press [Ctrl]+[Shift]+[Enter] before & after typing the formula otherwise you'll get a #VALUE error.

    Thanks again

+ 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. VBA to extract date from string
    By saravanan1981 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-09-2016, 11:33 AM
  2. extract a date from a text string
    By theobrandt in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-02-2016, 08:30 AM
  3. Extract date and time from a string
    By pickslides in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-19-2014, 09:07 PM
  4. [SOLVED] Extract a date from a string
    By DavidNO in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 12-19-2013, 05:55 PM
  5. Trying to use DateValue to extract date from string
    By mindtheGaspar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-28-2013, 07:01 PM
  6. Extract date from string
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-01-2011, 08:39 AM
  7. extract date from string
    By kdp145 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-03-2006, 10:54 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