+ Reply to Thread
Results 1 to 9 of 9

Function to clean up date/timestamp

  1. #1
    Registered User
    Join Date
    06-08-2009
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    9

    Function to clean up date/timestamp

    I have date/time data in the following form:

    Mon Jan 12 07:26:26 EST 2009

    I have tried multiple forms of LEFT, RIGHT, MID, etc. Date & Month are always three characters, but the date ("12" in this example) can vary between 1 or 2 characters.

    Any assistance you can offer would be fantastic!!
    Last edited by jwilds1; 06-11-2009 at 07:17 AM.

  2. #2
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Function to clean up date/timestamp

    =LEFT(C3,3)
    =MID(C3,FIND(" ",C3,3)+1,3)
    =MID(C3,9,FIND(" ",C3,9)-8)
    =MID(C3,FIND(" ",C3,9)+1,8)
    =MID(C3,FIND(" ",C3,17)+1,3)
    =RIGHT(C3,4)

    Assuming date is in cell c3 should return all the parts!

    =DATEVALUE(MID(C3,9,FIND(" ",C3,9)-8)&"-"&MID(C3,FIND(" ",C3,3)+1,3)&"-"&RIGHT(C3,4))
    excel date

    =TIMEVALUE(MID(C3,FIND(" ",C3,9)+1,8))
    excel time

    =DATEVALUE(MID(C3,9,FIND(" ",C3,9)-8)&"-"&MID(C3,FIND(" ",C3,3)+1,3)&"-"&RIGHT(C3,4))+TIMEVALUE(MID(C3,FIND(" ",C3,9)+1,8))
    excel date & Time
    Last edited by squiggler47; 06-08-2009 at 09:37 PM. Reason: Added last 3 functions
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  3. #3
    Registered User
    Join Date
    06-08-2009
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Function to clean up date/timestamp

    Thanks, but I'm getting #VALUE error in the FIND function. I've tried changing the FIND to SEARCH and still getting it. Any advice?

  4. #4
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Function to clean up date/timestamp

    you might be better posting a worksheet with a few time stamps in it from your sheet, I could only work of the example you gave me, and the spaces may not be real spaces!

    It worked for me when I pasted the exampel you gave into a blank sheet!

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Function to clean up date/timestamp

    An adaptation of squiggler's approach based on the fact that all apart from day are seemingly regimented:

    Please Login or Register  to view this content.
    Where

    A1: Mon Jan 12 07:26:26 EST 2009

    should also work if day is 1 char or 2.

  6. #6
    Registered User
    Join Date
    06-08-2009
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Function to clean up date/timestamp

    I've attached a file with the example timestamps.

    DonkeyOte - that worked, but I would also like the actual times. The goal of this is to subtract two timestamps, eventually coming up with a time between each entry (minutes, seconds).

    Thanks!!!!
    Attached Files Attached Files

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Function to clean up date/timestamp

    Not sure I follow, the formula I provided converts the string to a datetime value. You will however need to format the cell(s) containing the formulae to show the datetime in full (ie dd/mm/yyyy hh:mm:ss).

  8. #8
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Function to clean up date/timestamp

    Ok, you just needed to change the C3 to A2

    Here is datestamp reproduced with a custom format, it is now an excel time/date so can be formatted to any layout (examples in next 4 cols!
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    06-08-2009
    Location
    Detroit, MI
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: Function to clean up date/timestamp

    Thanks to both of you. I was in such a hurry I missed changing the formatting of DonkeyOte's solution.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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