+ Reply to Thread
Results 1 to 11 of 11

Convert Text into Date

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    Bratislava, Slovakia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Convert Text into Date

    Hello,
    could you please help me with formatting text into date, when text is in format dd/mm/yyyy and the date format should be like this mm/dd/yyyy?
    I tried Text import wizard and in helped, but some cells remained unchanged. I also tried some macros posted in here, but none of them really helped in my case

    Thank you so much

  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,733

    Re: Convert Text into Date

    Try this formula:

    =DATE(RIGHT(A1,4),MID(A1,4,2),LEFT(A1,2))

    where A1 contains your text-date. Format the cell as a date. You may need to use semicolons ( ; ) instead of the commas ( , ).

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    04-29-2013
    Location
    Bratislava, Slovakia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Convert Text into Date

    Hello Pete, excel is returning "#VALUE!" for this formula..

  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,733

    Re: Convert Text into Date

    Post an example file showing a range of your "date" values.

    Pete

  5. #5
    Registered User
    Join Date
    04-29-2013
    Location
    Bratislava, Slovakia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Convert Text into Date

    Here is the column with dates, that cannot be formated
    Attached Files Attached Files

  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,733

    Re: Convert Text into Date

    Your dates start in A2, not A1. Also, you have some "dates" formatted as d/m/yyyy and also some hyphens instead of dates.

    So, put this amended formula in B2:

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


    Format as you wish to see the date, then copy this down.

    Hope this helps.

    Pete
    Attached Files Attached Files

  7. #7
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Convert Text into Date

    @ Pete_UK,

    I am also looking at this Thread, and you came up with a nice formula. But there are also dates such as 04.04.2013, and oh boy!, am I having a hard time to tweak your formula!

    Is it even possible to cater for such intance as well?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Convert Text into Date

    Maybe something like;

    Please Login or Register  to view this content.
    or rather;

    Please Login or Register  to view this content.
    and copied down.

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

    Re: Convert Text into Date

    Yes, you could use SUBSTITUTE to change those full stops to a slash, like this in B2:

    =IF(A2="-","",DATE(RIGHT(A2,4),SUBSTITUTE(MID(SUBSTITUTE(A2,".","/"),FIND("/",SUBSTITUTE(A2,".","/"))+1,2),"/",""),LEFT(SUBSTITUTE(A2,".","/"),FIND("/",SUBSTITUTE(A2,".","/"))-1)))

    The first date like that occurs in row 590.

    There is also another problem date in row 575, where there is a double-slash. The same approach could be taken to change that // to /, or you could begin the formula with something like:

    =IF(LEN(A2)>10,"error", ...

    to alert the user to change the source data, as there could be many more such errors (like one date with letters in).

    Hope this helps.

    Pete

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Convert Text into Date

    @ Pete_UK,

    O.k. this SUBSTITUTE(MID(SUBSTITUTE(A2,".","/") is new to me, but why does the formula now return the year as 13 instead of 2013?

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Convert Text into Date

    @ Pete_UK,

    Please ignore my last post.

    It is a Cell formatting issue!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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