+ Reply to Thread
Results 1 to 10 of 10

Formatting text dates & times in Excel is a Bind!

  1. #1
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Formatting text dates & times in Excel is a Bind!

    Hi

    I imported a text file into Excel. There are cells with dates and times that I need to seperate between the dates and the times and format them in a particular way. Open the file and you see my request. I just can't seem to format the cells. Some of them do format, some don't and some fall in the middle: It's a mess.

    Can you help, please?
    Attached Files Attached Files
    Patish

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formatting text dates & times in Excel is a Bind!

    C5: =IF(B5="", "", MOD(B5,1))
    ...formatted as Time.

    D5: =IF(B5="", "", INT(B5))
    ...formatted as Date.

    Now copy those two cells downward.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Formatting text dates & times in Excel is a Bind!

    Hi Patish,

    Use below formula for Time:-
    =TIME(HOUR(B5),MINUTE(B5),SECOND(B5))

    and below formula for Date:-
    =DATE(YEAR(B5),MONTH(B5),DAY(B5))

    See attached: Closed Chks Room Service Aug 2012-01.xls


    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  4. #4
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Formatting text dates & times in Excel is a Bind!

    Have you tried formatting the cells in the Date/Time column as text during the import? This should stop Excel attempting to auto reformat.

    You could then use the TIMEVALUE and DATEVALUE functions on substrings.
    Martin

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

    Re: Formatting text dates & times in Excel is a Bind!

    Hi Patish

    Would this be something that you could work with.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Re: Formatting text dates & times in Excel is a Bind!

    Kevin

    You hit it rock solid. Thanks for the solution. A bit complicated, but effective. If you got time to explain it or is it inexplicable.

    Thanks to the others. Much appreciated.

    Thanks

    Patish

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

    Re: Formatting text dates & times in Excel is a Bind!

    It took me a while to get my head around it as the length of characters in column B ranged between 8-18 characters.
    For the dates I used a IF Function and for the logical test I used the ISTEXT to determine if it was text in Column B.If it was true I used the DATE Function, with Text functions to extract the date. IE: 8/18/2012. If it was FALSE I extracted the Integar.
    For the Times it was the same process as getting the dates, for the false part it was removing the Integar.
    Hopefully that explains it!

    And formating the columns as Dates and Times.
    Last edited by Kevin UK; 09-04-2012 at 12:14 PM.

  8. #8
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Re: Formatting text dates & times in Excel is a Bind!

    Thanks and much appreciated.

    Patish

  9. #9
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Formatting text dates & times in Excel is a Bind!

    @ Patish

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

  10. #10
    Forum Contributor
    Join Date
    09-19-2003
    Posts
    226

    Re: Formatting text dates & times in Excel is a Bind!

    Cutter
    My apologies. Thank you. I am satisfied.
    Patish

+ 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