+ Reply to Thread
Results 1 to 12 of 12

Converting annoying string to a Date format

  1. #1
    Registered User
    Join Date
    08-21-2019
    Location
    San Jose, CA
    MS-Off Ver
    365
    Posts
    8

    Converting annoying string to a Date format

    Greetings,

    I've got a tricky date string that I'm having trouble with in converting to an actual DATE. Kibana is kicking out date strings such as the following: July 22nd 2019 and August 21st 2019 I've played around with "Text to Column" and various functions but to no avail. I don't see any examples here that are quite like mine. It needs to apply to different month lengths and dump the "nd" and "st", etc..... Any ideas out there how to convert this column of data to an actual DATE type format?

    Thanks much,

    Mark

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: Converting annoying string to a Date format

    do you want it all in one formula or are you willing to take it apart in text to columns then recombined it into a date and what format, will July 22nd 2019 = 7/22/2019 for you?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Registered User
    Join Date
    08-21-2019
    Location
    San Jose, CA
    MS-Off Ver
    365
    Posts
    8

    Re: Converting annoying string to a Date format

    Hello,

    Single formula would be preferable. Yes, July 22nd 2019 = 7/22/2019 but also August 3rd 2019 = 8/3/2019. This is the tricky part for me, dealing with all the possibilities of length of month and day.

    Thank you for responding.

    Mark

  4. #4
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: Converting annoying string to a Date format

    Look here https://stackoverflow.com/questions/...-date-in-excel

    That should help you get rid of the ordinals and then you can use Format, DateValue or CDate after that to get the output you want.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

  5. #5
    Registered User
    Join Date
    08-21-2019
    Location
    San Jose, CA
    MS-Off Ver
    365
    Posts
    8

    Re: Converting annoying string to a Date format

    Yes, I have tried that by simply removing the ordinals you mention. But I'm unable to do a simple format change. DATEVALUE failing as well.

  6. #6
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: Converting annoying string to a Date format

    Ok, this is one ugly formula but it works in my data and is based on the premise that your text values are in A2...
    =DATEVALUE(LOOKUP(LEFT(A2,SEARCH(" ",A2)-1),{"April","August","December","February","January","July","June","March","May","November","October","September"},{4,8,12,2,1,7,6,3,5,11,10,9})&"/"&LOOKUP(9E+99+307,--MID(A2,MIN(SEARCH({1,2,3,4,5,6,7,8,9,0},A2&1234567890)),ROW(INDIRECT("1:"&LEN(A2)))))&"/"&RIGHT(A2,4))
    it will output a date in number format so you'll have to format the cell as date.

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,408

    Re: Converting annoying string to a Date format

    Give this formula a try (you will have to use Cell Formatting to change from the serial date value to a standard date display)...

    =0+REPLACE(A2,LEN(A2)-6,2,",")

  8. #8
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,496

    Re: Converting annoying string to a Date format

    Give this formula a try (you will have to use Cell Formatting to change from the serial date value to a standard date display)...
    =0+REPLACE(A2,LEN(A2)-6,2,",")
    Wow, double plus good! Pretty slick and much nicer than my clumsy one. Rep to you Rick!

  9. #9
    Registered User
    Join Date
    08-21-2019
    Location
    San Jose, CA
    MS-Off Ver
    365
    Posts
    8

    Re: Converting annoying string to a Date format

    Learning loads here, thank you so much

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Converting annoying string to a Date format

    Does

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    work for you. If not try switching the first two elements of the string around.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  11. #11
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Converting annoying string to a Date format

    Not as slick as Rick ( ), but this was my take...
    =--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"nd",","),"st",","),"rd",","),"th",",")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  12. #12
    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 annoying string to a Date format

    Here is another one

    =(LEFT(A1,LEN(A1)-7)&", "&RIGHT(A1,4))+0

    v A B
    1 July 22nd 2019 7/22/2019
    2 August 15th 2015 8/15/2015
    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

+ 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 from the 1904 date format to the 1900 date format without losing data
    By Patty McJorst in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2020, 12:53 PM
  2. [SOLVED] Converting Date & Time (General format) to Date (Date format)
    By supremenuts in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-22-2017, 12:55 PM
  3. Replies: 5
    Last Post: 02-08-2013, 11:06 AM
  4. Converting ddmmyy date format to text string
    By Fos605 in forum Excel General
    Replies: 1
    Last Post: 06-06-2008, 09:49 AM
  5. Converting Text String to Date Format
    By mccrimmon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-14-2007, 11:09 AM
  6. annoying date format
    By Barry Au in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2007, 04:09 PM
  7. Converting text string to a its proper time format
    By Edmund Wong in forum Excel General
    Replies: 3
    Last Post: 10-20-2005, 08:05 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