+ Reply to Thread
Results 1 to 8 of 8

Converting non-standard date format

  1. #1
    Forum Contributor
    Join Date
    01-26-2018
    Location
    London, England
    MS-Off Ver
    365
    Posts
    311

    Converting non-standard date format

    Hi all,

    Another date format problem..

    My data arrives in 3 columns (A,B,C) (Month Day, Year, Time) & I'm trying to convert it into "DD/MM/YYYY HH:MM" (Col D).

    Should be simple, but I keep getting value errors & datevalue throws up strange results

    Thanks
    Mdn
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    24,033

    Re: Converting non-standard date format

    Power Query Solution

    Please Login or Register  to view this content.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    01-26-2018
    Location
    London, England
    MS-Off Ver
    365
    Posts
    311

    Re: Converting non-standard date format

    Hi Alan, cheers for the solution, but how do I apply the code? I'm a total noob when it comes to power query (never used it; quickly reading about it now!).

    I pasted it into the advanced editor, but received this error:

    Attachment 764414

  4. #4
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,427

    Re: Converting non-standard date format

    If you are interested in a formula solution please try this in D2 and copy down. You will need to Custom format for date / time as m/d/yyyy h:mm
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    or to be on the safe side
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    and custom format as before.

    I edited before refreshing and missed Mr. Shorty's intercept. Thank you Mr. Shorty.
    Last edited by FlameRetired; 01-20-2022 at 06:37 PM.
    Dave

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,934

    Re: Converting non-standard date format

    This formula based solution worked for me:

    1) Split the date column into month and day columns. You can use Text to columns for this with space as the delimiter, skip the first (blank) column, and have the destination be G2 (so it doesn't overwrite any of the source data).
    2) Enter a table of month names. Assuming your data will always use a 3 character abbreviation for the month name, the list would be Jan, Feb, Mar,...,Nov,Dec.
    3) Use a MATCH() function on this list to get the month number and put the day, month number, year into a DATE() function to get the date serial number =DATE(B2,MATCH(G2,$M$1:$M$12,0),H2
    4) Use a TIMEVALUE() function to get the serial number for the time, and add it to step (3) =DATE(....)+TIMEVALUE(C2). Copy/paste/fill down as far as needed.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,934

    Re: Converting non-standard date format

    Expanding on Flameretired's solution (which will always assume the current year -- which is fine if all dates will be 2022 dates), this also worked for me:

    1) My computer's OS regional settings expect a long date format of mmm d, yyyy, so I concatenate the date and year columns into something the computer can recognize A2&", "&B2
    2) Put that in a DATEVALUE() function =DATEVALUE(A2&", "&B2)
    3) As before, add the TIMEVALUE() to get the full date/time serial number =DATEVALUE(A2&", "&B2)+TIMEVALUE(C2)

    The main downside I see to the DATEVALUE() function, and why I usually prefer the DATE() function is that the DATEVALUE() function relies on your computer's regional OS settings in order to interpret the input text. It is sometimes difficult -- especially if this needs to work across multiple computers that may have different regional settings -- to piece together a reliable input text for the DATEVALUE() function that will always work. Going to the extra effort to get year, month, and day numbers from the input text is that you can then put together a DATE() function that will consistently and reliably convert the text to serial number.
    Last edited by MrShorty; 01-20-2022 at 06:35 PM.

  7. #7
    Forum Contributor
    Join Date
    01-26-2018
    Location
    London, England
    MS-Off Ver
    365
    Posts
    311

    Re: Converting non-standard date format

    Lovely stuff lads

    Many thanks

  8. #8
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 v 2405
    Posts
    13,427

    Re: Converting non-standard date format

    You are welcome. Thank you for the feedback and marking your thread 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. [SOLVED] converting ss:000 to standard time format
    By natouk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-02-2020, 04:32 PM
  2. Converting a julian date and time to standard date in excel 2010
    By Munkle555 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2015, 10:49 AM
  3. Replies: 4
    Last Post: 05-10-2014, 10:45 AM
  4. [SOLVED] Converting Standard Time format (hh:mm:ss) to number of minutes
    By xygrax in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-27-2014, 10:54 AM
  5. Replies: 5
    Last Post: 02-08-2013, 11:06 AM
  6. Converting all date formats to one single standard format.
    By booo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-25-2010, 07:14 PM
  7. converting "strange" date format to standard date format
    By perinouk in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-01-2007, 02:09 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