+ Reply to Thread
Results 1 to 9 of 9

Excel Formatting to Date/Time

  1. #1
    Registered User
    Join Date
    07-16-2013
    Location
    Oxnard, California
    MS-Off Ver
    Excel 2007
    Posts
    44

    Excel Formatting to Date/Time

    Hello,

    I imported a txt file into excel and one column returned date and time like this: 01 Apr 2013 0821 (with spaces). How can I convert that into a format that Excel will then recognize as a date/time value that I can use for formulas? Thank you.

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

    Re: Excel Formatting to Date/Time

    If your data/time is in A1, you can use this formula (e.g. in B1):

    =DATEVALUE(LEFT(A1,11))+TIME(MID(A1,13,2),RIGHT(A1,2),0)

    Format the cell using a custom format in the style you wish to see it (e.g. mm/dd/yyyy hh:mm)

    Hope this helps.

    Pete

  3. #3
    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
    52,929

    Re: Excel Formatting to Date/Time

    Hi and welcome to the forum

    Assuming your data is always in that format, and assuming it is in A1, downwards, use this, copied down...

    =DATEVALUE(MID(A1,1,LEN(A1)-5))+TIME(LEFT(RIGHT(A1,4),2),RIGHT(RIGHT(A1,4),2),0)
    custome format "dd mmm yyyy h:mm AM/PM"

    edit: lol, love it Pete same but different
    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

  4. #4
    Registered User
    Join Date
    07-16-2013
    Location
    Oxnard, California
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Excel Formatting to Date/Time

    Thank you! It worked!

  5. #5
    Registered User
    Join Date
    07-16-2013
    Location
    Oxnard, California
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Excel Formatting to Date/Time

    Do either of you have a moment to explain the the commands: (left, mid, right) and (11,13,2). I want to try to understand the concept, so I can do this on my own next time. I have an Excel 2010 bible, but it doesnt quite explain what these commands do. I appreciate your time!

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

    Re: Excel Formatting to Date/Time

    Those act on a string of text to return the LEFT-most characters, or characters from the MIDdle of the string, or the RIGHT-most characters. For LEFT and RIGHT you need to specify the numbers of characters that you need, but for the MID function you need to specify the character number that you want to start with AND the number of characters that you want to extract, so LEFT(A1,11) returns the first 11 characters of the string in A1, and RIGHT(A1,2) returns the final two characters of A1, and MID(A1,13,2) returns 2 characters from A1 starting with the 13th character.

    You can find more details (and examples) of these functions in XL Help (press F1).

    Hope this helps.

    Pete

  7. #7
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Excel Formatting to Date/Time

    Try this shorter version:

    =--REPLACE(A1,15,,":")

  8. #8
    Registered User
    Join Date
    07-16-2013
    Location
    Oxnard, California
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Excel Formatting to Date/Time

    Thank you!!

  9. #9
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Excel Formatting to Date/Time

    You're Welcome!

+ 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. modify date time cell to an excel format date time
    By rileyp in forum Excel General
    Replies: 12
    Last Post: 03-24-2013, 08:39 PM
  2. date and time formatting
    By eturn in forum Excel General
    Replies: 7
    Last Post: 01-26-2011, 07:04 PM
  3. Date and time formatting
    By Mayank Trivedi in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 03-10-2008, 03:01 PM
  4. Date and Time formatting
    By aknapp in forum Excel General
    Replies: 1
    Last Post: 07-06-2007, 01:18 AM
  5. [SOLVED] Date and time formatting
    By Marco in forum Excel General
    Replies: 7
    Last Post: 02-25-2005, 07:06 PM

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