+ Reply to Thread
Results 1 to 30 of 30

Formula to convert awkward date format

  1. #1
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Formula to convert awkward date format

    Hi,

    I am using a public data source to extract data and the date format is something I can't fix into an excel recognized format. Example below

    Sun, Nov 10, 13
    Sat, Nov 9, 13

    I have tried mid-function to extract the constituent pieces but the character length is not consistent as the date could be 1 OR 2 numbers, so I haven't been able to work out a solution.

    The ideal format is:
    dd-mmm-yyyy.

    Help appreciated, thanks.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Formula to convert awkward date format

    This works in the USA

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Then format the cell in appropriate Date format
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    Try
    =REPLACE(A1,1,5,"")+0

    And format the cell with the formula as dd-mmm-yyyy

  4. #4
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Formula to convert awkward date format

    A1 = "Sun, Nov 10, 13"
    A2 = DATEVALUE( RIGHT(A1, LEN(A1) -5) )

    A2 held an excel date serial number, so then I just set the cell format to dd-mmm-yyyy and it was fine.

    Well, the way this works is it trims the day-of-week off the front and then lets excel figure out the remaining "mmm dd, yy" string. You might need to make that -5 more intellingent if the day code isn't always three letters long, like if Thursday is "Thurs" or something, by using FIND(",", A1, 1)+1 for example.

  5. #5
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    I have tried all 3 of these formulas and each one returns #VALUE! error. What am i doing wrong?

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    That would mean your cells don't contain 'Exactly' what you've posted.
    Perhaps they are actually real dates already, and all you need to do is go into format Cells, and change the format to
    Custom
    dd-mmm-yyyy

    Can you post a sample workbook?

  7. #7
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    date formatting - rank.xlsx

    File attached. I can't see any difference between the file and what was posted - and i can't format the data as serial numbers in the pre-existing format.

    probably missing something basic..>!

  8. #8
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    There is something wierd about the data in column A
    If I select A2, and press F2 then Enter, then it works.

    It's something about how the data is imported.

    Try copying A2:A21
    Then Paste Special Values right back ontop of itself.

  9. #9
    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
    53,048

    Re: Formula to convert awkward date format

    Yes I tried that too Jon, F2-enter and it calcs file, copied it off to the side and pasted back, it worked fine, copy, paste without moving the cursor, it worked fine

    Not sure what the problem is but I will check further
    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

  10. #10
    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
    53,048

    Re: Formula to convert awkward date format

    dchubbock, where is this data coming from?

  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
    53,048

    Re: Formula to convert awkward date format

    OK this seems to work...
    =DATEVALUE(MID(A2,6,99))

  12. #12
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    When I try copy paste special values i get the same Value error.

    I've tried re-importing and pasting in different ways but no joy (the data is originally from an HTML webpage)

    Very frustrating. Ideas most welcome

  13. #13
    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
    53,048

    Re: Formula to convert awkward date format

    Did you try my suggestion in post # 11?

  14. #14
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    Quote Originally Posted by dchubbock View Post
    When I try copy paste special values i get the same Value error.
    This seems to contradict what you said in post #9

    Quote Originally Posted by FDibbins View Post
    Yes I tried that too Jon, F2-enter and it calcs file, copied it off to the side and pasted back, it worked fine, copy, paste without moving the cursor, it worked fine

  15. #15
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    Yes, same result: #VALUE!

  16. #16
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    Hi Jon, FDibbins made the second comment - maybe he managed to past special values but it didn't work for me...

  17. #17
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    Quote Originally Posted by dchubbock View Post
    Hi Jon, FDibbins made the second comment - maybe he managed to past special values but it didn't work for me...
    My Bad, sorry...


    What is your system's default date format? (although I don't think that would matter in a date using spelled months..)
    If you format a blank empty cell as General.
    And type in a date
    What format does it show by default

    What exactly did you type?
    How exactly does it show it after you press enter?

  18. #18
    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
    53,048

    Re: Formula to convert awkward date format

    see the attached where I used my formula from post # 11
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    No worries Jon

    If I type 20/03/2013 in a cell with general format applied, then press enter it changes to a date format, it views exactly as typed.
    If I type 20-March-2013 in a cell with general format applied, then press enter it changes to a date format, it views 20-Mar-2013

    FDibbins - when i opened the attached file all formulas return value error, inc. your latest one in column G.

  20. #20
    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
    53,048

    Re: Formula to convert awkward date format

    FDibbins - when i opened the attached file all formulas return value error, inc. your latest one in column G.
    Ok that is strange then, this what I get...
    A
    B
    C
    D
    E
    F
    G
    1
    Date rank rank2 Formula 1 Formula 2 Formula 3
    2
    Wed, Nov 20, 13
    14
    3
    11/20/2013
    41598
    41598
    11/20/2013
    3
    Wed, Nov 13, 13
    13
    9
    11/13/2013
    41591
    41591
    11/13/2013
    4
    Tue, Nov 26, 13
    1
    1
    11/26/2013
    41604
    41604
    11/26/2013
    5
    Tue, Nov 19, 13
    14
    1
    11/19/2013
    41597
    41597
    11/19/2013
    6
    Tue, Nov 12, 13
    13
    2
    #VALUE!
    #VALUE!
    #VALUE!
    11/12/2013
    7
    Thu, Nov 7, 13
    #VALUE!
    #VALUE!
    #VALUE!
    11/7/2013
    8
    Thu, Nov 21, 13
    14
    134
    #VALUE!
    #VALUE!
    #VALUE!
    11/21/2013


    Is this the only time you are getting strange/wired results? I wonder if you need to repair/reinstall Office?

  21. #21
    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: Formula to convert awkward date format

    This worked for me

    =--TRIM(MID(A1,6,10))
    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

  22. #22
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Formula to convert awkward date format

    This formula

    =DATEVALUE(MID(A2,6,99))

    and this one...

    DATEVALUE( RIGHT(A1, LEN(A1) -5) )

    and this one..

    =REPLACE(A1,1,5,"")+0

    all essentially do the same but none will work with UK regional settings because Nov 10, 13 isn't a valid date format in the UK
    Audere est facere

  23. #23
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    Try
    =(MID(SUBSTITUTE(A2,",",""),9,2)&" "&MID(A2,6,3)&", "&RIGHT(A2,2))+0

  24. #24
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Formula to convert awkward date format

    Yep, that one works in UK Jonmo, you could also try this

    =SUBSTITUTE(REPLACE(A2,1,9,""),", ",MID(A2,6,3)&20)+0

    and format result cell in required date format

  25. #25
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    Quote Originally Posted by daddylonglegs View Post
    =SUBSTITUTE(REPLACE(A2,1,9,""),", ",MID(A2,6,3)&20)+0
    Nice,

    That one works in Either UK or US date format.
    Assuming the year is always in the 21st century

  26. #26
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,695

    Re: Formula to convert awkward date format

    Yeah, I suppose you don't need the 20, it works with

    =SUBSTITUTE(REPLACE(A2,1,9,""),", ",MID(A2,6,3))+0

    and then the years will be converted as per your regional settings

  27. #27
    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
    53,048

    Re: Formula to convert awkward date format

    Good catch, DDL

  28. #28
    Registered User
    Join Date
    03-31-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    84

    Re: Formula to convert awkward date format

    Fantastic! That formula works perfectly.

    Thanks everyone for all your help!

    Dan

  29. #29
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Formula to convert awkward date format

    You're welcome.

  30. #30
    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
    53,048

    Re: Formula to convert awkward date format

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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. [SOLVED] Require vba or formula for convert general format data in date format
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-10-2013, 03:53 AM
  2. [SOLVED] How to use a formula or function to convert a plain number into a date format
    By Liam Ryan in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 07-02-2013, 07:48 AM
  3. Formula to convert to date format
    By Excel Dumbo in forum Excel General
    Replies: 4
    Last Post: 09-25-2012, 03:02 AM
  4. Need Formula/VBA Code to convert date in String Format to Normal Date format
    By Karthik Sen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-18-2012, 04:54 AM
  5. Formula to convert text to a date in a date format
    By mikeburg in forum Excel General
    Replies: 5
    Last Post: 08-24-2011, 09:15 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