+ Reply to Thread
Results 1 to 5 of 5

convert Date Time format

  1. #1
    Registered User
    Join Date
    12-30-2009
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    6

    convert Date Time format

    Need VBA Script to convert DateTime format to Date and Time in separate columns

    Details:

    I have a cell with 30/12/2009 00:01:16 (DATETIME format), I need to separate the date and time in two separate columns

    Is there any macro instead of using TEXT TO COLUMNS to do this?

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    re: convert Date Time format

    Hello yourskarthik,

    I doubt you need VBA to do this if the information is already on the worksheet. You could do this by changing the cell formatting and copying the date into the appropriate cells using formulas. What are you doing that makes you think you need a VBA solution?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-30-2009
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    6

    re: convert Date Time format

    Hello Leith Ross,

    I have the data in the excel but the thing is Column A contains Time Stamp in DATETIME format (Please see the attached)

    I need to have column B with DATE and Column C with Time (HH:MM format instead of HH:MM:SS)

    Yes I can do this by changing the format but everytime I have to do TEXT TO COLUMNS and then change the format which is annoying..
    Attached Files Attached Files

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: convert Date Time format

    Surely you can pre-format the columns. Text to Columns splits the time element to Column B which I had already formatted as hh:mm with no problem
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: convert Date Time format

    Hello yourskarthik,

    It would be easier to understand what you need if you could post a workbook with the data imported using text to columns. If you do need a macro for this then knowing the data layout is essential.

+ 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