+ Reply to Thread
Results 1 to 7 of 7

Extract "Time" from custom "Date and Time" format

  1. #1
    Registered User
    Join Date
    08-17-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Extract "Time" from custom "Date and Time" format

    Hello!

    I have a file that has the Date and Time combined into one cell. I want to separate the two, and cannot find anywhere on the net to do so!

    This is the cells format:
    d/mm/yyyy h:mm

    Cells look like this:
    28/05/2008 12:30

    Does anyone know how to separate these with VBA code? changing the cell format changes the look of the cell, but the underlying numbers are still the same. Any ideas?

    Cheers
    Last edited by ben_patto; 09-24-2009 at 08:48 PM.

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

    Re: Extract "Time" from custom "Date and Time" format

    So are you looking to override the DateTime with Date and push Time into adjacent cell ?

    (in VBA terms you can use .Text and split by space else remember that Dates are Integers and Time is Decimal...)

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

    Re: Extract "Time" from custom "Date and Time" format

    I'm heading offline shortly but assuming you want to split such that datetime values in A become date only in A and time only in B then:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    08-17-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Extract "Time" from custom "Date and Time" format

    Thank you! works great! does exactly what I wanted!

    Cheers

  5. #5
    Registered User
    Join Date
    08-17-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Extract "Time" from custom "Date and Time" format

    what would the code look like if I wanted to store the two values into an array rather than offsetting them to other cells?

    Say shift_time(i) and shift_date(i)?

    I keep getting an error message when i change the above code?

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

    Re: Extract "Time" from custom "Date and Time" format

    Along the lines of:

    Please Login or Register  to view this content.
    the transpose is not strictly required

  7. #7
    Registered User
    Join Date
    08-17-2009
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    17

    Re: Extract "Time" from custom "Date and Time" format

    Excellent! Thankyou very much!

+ 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