+ Reply to Thread
Results 1 to 15 of 15

Modifying and separating Date & Time from single cell

  1. #1
    Registered User
    Join Date
    05-07-2013
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Modifying and separating Date & Time from single cell

    Hello,

    I have a string of the following text in one column:
    May 2 2013 08:54:46:827AM

    How it is possible to change it to the following:
    2.05.2013 8:54:23

    Date and time in the separate columns.
    8:54:23 - military time

    Maybe something like that could do the trick?
    =REPLACE(REPLACE(A1,FIND(":",A1)-2,9,MID(A1,2,FIND(" ",A1,2)-1)),1,FIND(" ",A1,2),"")+LEFT(RIGHT(A1,13),8)+0

    (Don't have enough knowledge to modify that formula)
    file attached
    excel issue.xls
    Last edited by happyc; 05-07-2013 at 03:27 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Modifying and separating Date & Time from single cell

    Try setting the numberformat of the cell to .... custom ->> d.mmm.yyyy h:mm:ss

    If it displays correctly you are dealing with a numerical date otherwise it is a string..
    Once we know the answer to the above question we will know how best to proceed..

    I couldn't open your file...
    Elegant Simplicity............. Not Always

  3. #3
    Registered User
    Join Date
    05-07-2013
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Modifying and separating Date & Time from single cell

    Nothing changes.
    The line stays the same - May 2 2013 08:54:46:827AM

    Uploaded excel file for Office 2010
    excel.xlsx

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Modifying and separating Date & Time from single cell

    Use Text to columns function. First separate dates from time and split the time in to :

  5. #5
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Modifying and separating Date & Time from single cell

    The formula to pull the date from B2 could be

    =DATE(VALUE(TRIM(MID($B2,FIND(" ",$B2,FIND(" ",B2,1)+1)+1,FIND(" ",$B2,FIND(" ",$B2,FIND(" ",B2,1)+1)+1)-FIND(" ",$B2,FIND(" ",B2,1)+1)))),MATCH(LEFT(B2,FIND(" ",B2,1)-1),MonthList,0),VALUE(TRIM(MID($B2,FIND(" ",B2,1)+1,FIND(" ",$B2,FIND(" ",B2,1)+1)-FIND(" ",B2,1)))))

    Where "MonthList" is a list of the 12 months written as they appear in the main data

  6. #6
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Modifying and separating Date & Time from single cell

    The time is

    =TIME(LEFT(RIGHT(B2,LEN(B2)-FIND("~",SUBSTITUTE(B2," ","~",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))))),2),MID(RIGHT(B2,LEN(B2)-FIND("~",SUBSTITUTE(B2," ","~",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))))),4,2),MID(RIGHT(B2,LEN(B2)-FIND("~",SUBSTITUTE(B2," ","~",LEN(B2)-LEN(SUBSTITUTE(B2," ",""))))),7,2))

  7. #7
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modifying and separating Date & Time from single cell

    This workbook might suit your needs, the formulae are a tad shorter.

    [EDIT]
    @ Andy
    Does your time formula handle AM/PM?
    Attached Files Attached Files
    Last edited by Marcol; 05-07-2013 at 06:26 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  8. #8
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Modifying and separating Date & Time from single cell

    Ahhh ... good point Marcol - NO it doesn't ...

  9. #9
    Registered User
    Join Date
    05-07-2013
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Modifying and separating Date & Time from single cell

    Marcol's file worked as a charm.
    Thank you guys!

  10. #10
    Registered User
    Join Date
    05-07-2013
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Modifying and separating Date & Time from single cell

    I am sorry, just found a small issue when using formulas from Marcol's worksheet.

    12 PM returns 0:00:00
    While 12 AM returns 12:00:00

    Should be vise versa.
    Is there any way around it?


    May 1 2013 12:05:22:260PM 1.05.2013 0:05:22
    May 1 2013 12:54:13:387PM 1.05.2013 0:54:13

  11. #11
    Registered User
    Join Date
    05-07-2013
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Modifying and separating Date & Time from single cell

    Excel file enclosed for better illustration:
    am-pm issue.xlsx

    Thanks you,
    Anton

  12. #12
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Modifying and separating Date & Time from single cell

    Hi happyc

    See the attached for another version. The times in column C are assuming the times in column A are always 8 digits long eg: May 1 2013 11:30:38:170PM
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  13. #13
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modifying and separating Date & Time from single cell

    My apologies I missed the 12AM/12PM scenarios ...

    To keep things simple I would insert a helper column to return the hour from the TIMEVALUE() formula, Column D in this workbook.
    This can be hidden with the +/- grouping button.

    I have included a column to expand the formula if you dont want the helper, and similarly for the date without a lookup table.

    Note the change in the formula in C2, it now handles either of these TimeStamp format possibilities
    Dec 2 2013 08:54:23:903AM
    December 2 2013 08:54:23:903AM

    [EDIT]
    Go with Kevin, he's thinking ... I'm not!
    Attached Files Attached Files
    Last edited by Marcol; 05-08-2013 at 06:56 AM.

  14. #14
    Registered User
    Join Date
    05-07-2013
    Location
    Estonia
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: Modifying and separating Date & Time from single cell

    Thank you Kevin, worked great.

  15. #15
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Modifying and separating Date & Time from single cell

    Following Kevins' thinking this shorter formula seems to work for the date.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Good line of approach Kevin ...

+ 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