+ Reply to Thread
Results 1 to 11 of 11

Help need for converting a string date to yyyy-mm-dd

  1. #1
    Forum Contributor
    Join Date
    09-01-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, Excel 2013, Excel 2016
    Posts
    115

    Help need for converting a string date to yyyy-mm-dd

    Hi All,

    I have attached an excel file with some sample data. Column A has a stringed datatype like Wednesday, January 02 2013 and I just can't seem to find anyway to convert it to yyyy-mm-dd.

    I've been at it for a couple days now and have decided to ask for you expertise in this matter.

    Any help will be immensely appreciated.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Help need for converting a string date to yyyy-mm-dd

    =DATE(RIGHT(A2;4);FIND(MID(A2;FIND(",";A2)+3;2);" anebarprayunulugepktovec")/2;LEFT(RIGHT(A2;7);2))
    and format or TEXT with the same format
    Attached Files Attached Files
    Last edited by BMV; 01-23-2020 at 04:47 AM. Reason: Typo correction

  3. #3
    Forum Contributor
    Join Date
    09-01-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, Excel 2013, Excel 2016
    Posts
    115

    Re: Help need for converting a string date to yyyy-mm-dd

    Thanks BMV for the solution, much appreciated. By the way what does " anebsrprayunulugepktovec" do? I have never seen that before.

  4. #4
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Help need for converting a string date to yyyy-mm-dd

    Quote Originally Posted by spittingfire View Post
    By the way what does " anebsrprayunulugepktovec" do?
    FIND(",";A2)+3;2);" anebarprayunulugepktovec")/2 - is shortest way to get number of month from name and it's not depending from regional settings. For some language combination of 2nd and 2rd characters in the month name is unical
    "_JanFebMarAprMayJunJulAugSepOktNovDec". Find return 2,4,6.... and after /2 we will have number of month.
    Howeever I have typo and corrected formula in #2
    Last edited by BMV; 01-24-2020 at 12:31 AM.

  5. #5
    Forum Contributor
    Join Date
    09-01-2013
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, Excel 2013, Excel 2016
    Posts
    115

    Re: Help need for converting a string date to yyyy-mm-dd

    Thanks for the explanation BMV. I understand it now. Much appreciated.

  6. #6
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    179

    Re: Help need for converting a string date to yyyy-mm-dd

    I have one question about your explanation. Wouldn't "an" the second and third characters in January, return 1, not 2. Then if you divide by 2, you would have 1/2, which would not give the correct number of the month. The only part I don't get now is the divide by 2.

  7. #7
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Help need for converting a string date to yyyy-mm-dd

    Before strange string the space have been inserted. so "an" started from 2nd character of " aneb…."
    it could looks like (FIND(MID(A2,FIND(",",A2)+3,2);"anebarprayunulugepktovec")+1)/2 but longer.
    also
    (FIND(MID(A2,FIND(",",A2)+2,3);"JanFebMarAprMayJunJulAugSepOktNovDec")+2)/3 or
    FIND(MID(A2,FIND(",",A2)+2,3);"--JanFebMarAprMayJunJulAugSepOktNovDec")/3

  8. #8
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Help need for converting a string date to yyyy-mm-dd

    Another way

    =TRIM(SUBSTITUTE(RIGHT(SUBSTITUTE(A2,",",REPT(" ",255)),255),RIGHT(A2,5),", "&RIGHT(A2,4)))*1
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  9. #9
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Help need for converting a string date to yyyy-mm-dd

    Quote Originally Posted by Ace_XL View Post
    Another way
    it's true but only in the case if regional setting allow it. For me it's not so. However the same could be done easy
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    11-15-2008
    Location
    Arizona
    MS-Off Ver
    Excel 2013
    Posts
    179

    Re: Help need for converting a string date to yyyy-mm-dd

    Yes, I understood the string had a space inserted before an. I get that 2 and 3 characters give one "an," but the month of January is 1. SO what I don't get is the dividing by 2.

    =DATE(RIGHT(A2;4);FIND(MID(A2;FIND(",";A2)+3;2);" anebarprayunulugepktovec") = THIS part of the formula returns January as a number, which is 1

    =DATE(RIGHT(A2;4);FIND(MID(A2;FIND(",";A2)+3;2);" anebarprayunulugepktovec")/2= I don't understand the divide by 2. 1 divided by 2, does not give 1, which is what they need to be January. Could you just explain the divide by 2 part?

  11. #11
    Forum Expert BMV's Avatar
    Join Date
    01-13-2020
    Location
    St-Petersburg, Russia
    MS-Off Ver
    2013-2016
    Posts
    1,329

    Re: Help need for converting a string date to yyyy-mm-dd

    Quote Originally Posted by dsrt16 View Post
    =DATE(RIGHT(A2;4);FIND(MID(A2;FIND(",";A2)+3;2);" anebarprayunulugepktovec") = THIS part of the formula returns January as a number, which is 1
    you are wrong. The result of FIND will be 2 . FIND("an"," anebarprayunulugepktovec") return 2 because 1st char is " " , 2nd "a", 3rd "n".

+ 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] VBA convert string to date dd/mm/yyyy
    By alexcon in forum Excel General
    Replies: 3
    Last Post: 02-07-2018, 06:01 AM
  2. [SOLVED] How to convert a set of string into date MM-YYYY format
    By Acan in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-30-2014, 06:29 AM
  3. Converting dates: YYYY-MM-DD into DD Month YYYY
    By jacopo in forum Excel General
    Replies: 3
    Last Post: 10-21-2014, 07:39 PM
  4. Converting date from various forms to mm/dd/yyyy format
    By Sud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-20-2012, 07:38 PM
  5. Converting Six Digit Number to MM/YYYY Date Format
    By bschmeec in forum Excel General
    Replies: 1
    Last Post: 12-22-2011, 06:55 PM
  6. Replies: 3
    Last Post: 12-14-2009, 12:04 PM
  7. Problems converting date from d/m/yyyy to mmmm format
    By dcgrove in forum Excel General
    Replies: 6
    Last Post: 07-22-2009, 01:25 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