+ Reply to Thread
Results 1 to 9 of 9

Help in formatting mixed dates

  1. #1
    Registered User
    Join Date
    06-12-2017
    Location
    Victoria, Australia
    MS-Off Ver
    Office365
    Posts
    39

    Help in formatting mixed dates

    Hello peeps

    I am importing data from a system into Excel, but the date formatting for records is mixed - the data has both date and date-as-text string records. As an aside, the data format is in mm/dd/yyyy, while I am using a system date of d/mm/yyyy, and require to reformat the dates also to d/mm/yyyy.

    I have attempted a multi-step approach but encounter an issue in formatting the date-as-text strings. Here's a sample of the data I'm working with:

    dateformats.PNG

    As indicated, I'm working with data that has records formatted as dates as well as dates-as-text.

    My formula in Column D is: =TEXT((LEFT(F47,10)),"d/mm/yyyy")

    My formula in Column B is: =DATE((RIGHT(D47,4)),(LEFT(D47,2)),(MID(D47,4,2)))

    Column F contains the imported data.

    My aim is to convert all dates into the format of d/mm/yyyy, and to lose the timestamps. It seems that I am close but encounter a #Value error for record examples from lines 62 onwards, for the dates-as-text records where the month has a value of less than 10 (ie. October converts just fine, but September does not).
    Attached Files Attached Files
    Last edited by mwot; 12-11-2018 at 02:00 AM. Reason: adding sample data as attachment

  2. #2
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Help in formatting mixed dates

    Because when you do your left function taking 2 characters it is grabbing the digit and slash.

    You might be better attaching your sample data.

    Go Advanced -> Manage Attachments -> Upload

  3. #3
    Registered User
    Join Date
    06-12-2017
    Location
    Victoria, Australia
    MS-Off Ver
    Office365
    Posts
    39

    Re: Help in formatting mixed dates

    Sample data now attached to the original post.

    Looks like you're right re: the left function. I'm open to suggestions on how to best achieve the result I'm after.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Help in formatting mixed dates

    Please try

    =SUBSTITUTE(TRIM(MID(SUBSTITUTE(LEFT(TEXT(F25,"dd/mm/yyyy"),10),"/",REPT(" ",10)),10,10)&REPLACE(SUBSTITUTE(LEFT(TEXT(F25,"dd/mm/yyyy"),10),"/",REPT(" ",10)),10,10,""))," ","/")
    Last edited by Bo_Ry; 12-11-2018 at 02:20 AM.

  5. #5
    Registered User
    Join Date
    06-12-2017
    Location
    Victoria, Australia
    MS-Off Ver
    Office365
    Posts
    39

    Re: Help in formatting mixed dates

    Thanks, that removes the need for my extra formula in Column D, and works for records up to row 61; row 62 and on still results in the #Value error.

  6. #6
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: Help in formatting mixed dates

    I advice you to change system date format.
    >Start > Control Panel > Region Language > Additional Setting > Date Tab > Short Date Format as: dd-MM-yyyy > Long Date Format as: dd MMMM yyyy
    Then importing data from a system into Excel.


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark thread as solved".

  7. #7
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: Help in formatting mixed dates

    I fixed the dates by using Power Query if you have access to that. See attached.
    Attached Files Attached Files

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Help in formatting mixed dates

    Try again

    D25
    =TRIM(TEXT((LEFT(F25,10)),"dd/mm/yyyy"))

    B25
    =DATE(RIGHT(D25,4),LEFT(D25,FIND("/",D25)-1),MID(D25,FIND("/",D25)+1,2))

    Or revise Post#4 formula without helper column
    H25
    =SUBSTITUTE(TRIM(MID(SUBSTITUTE(LEFT(TEXT(F25,"dd/mm/yyyy"),10),"/",REPT(" ",9)),9,9)&REPLACE(SUBSTITUTE(LEFT(TEXT(F25,"dd/mm/yyyy"),10),"/",REPT(" ",9)),9,9,""))," ","/")
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-12-2017
    Location
    Victoria, Australia
    MS-Off Ver
    Office365
    Posts
    39

    Re: Help in formatting mixed dates

    Thanks, Bo_Ry - that solution seems to have worked a treat and achieves what I am after.

    Kersplash - I have Office 2016, so have access to Power Queries (though never used them - will do some research as it may help me in future )

    Thanks everyone for your prompt input and help.

    **SOLVED**

+ 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. Replies: 8
    Last Post: 07-07-2018, 03:27 AM
  2. Cells with mixed formatting
    By missydanni in forum Excel General
    Replies: 1
    Last Post: 10-13-2016, 07:47 AM
  3. dates appearing as generic code when mixed with text in a formula
    By mtleigh in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-06-2016, 05:29 AM
  4. Mixed dates that need to all be the same format
    By aigo in forum Excel General
    Replies: 2
    Last Post: 12-06-2013, 06:48 AM
  5. Replies: 7
    Last Post: 07-10-2013, 09:45 PM
  6. Replies: 8
    Last Post: 02-21-2010, 11:33 AM
  7. [SOLVED] Adding Column of mixed data omitting the dates
    By lpullen in forum Excel General
    Replies: 2
    Last Post: 11-17-2005, 12:45 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