+ Reply to Thread
Results 1 to 4 of 4

extract time from date/time for sorting

  1. #1
    Registered User
    Join Date
    06-06-2011
    Location
    brooklyn
    MS-Off Ver
    Excel 2003
    Posts
    8

    extract time from date/time for sorting

    Hi all,

    Have a data dump that puts the date/time in a cell together (5/23/11 12:41 AM), which I need in one place so that everything is in order of the actual time it came in, but I also want to run a chart based on the time of day (hour) disregarding the dates. Even if it's formatted as HH:MM only, it still sorts by day. How can I make the data sort by time, regardless of the date in the cell? I can add another column, but I don't know how to pull only the hh:mm info out of the date cell. Alternatively, is there a way to sort the data in a chart without sorting it in the generating table?

    Thanks!
    Last edited by always Stumped; 06-07-2011 at 01:32 AM.

  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: extract time from date/time for sorting

    A1 - Date/Time
    B1: =MOD(A1, 1) (formatted as time)
    _________________
    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
    Registered User
    Join Date
    06-06-2011
    Location
    brooklyn
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: extract time from date/time for sorting

    Quote Originally Posted by JBeaucaire View Post
    A1 - Date/Time
    B1: =MOD(A1, 1) (formatted as time)
    perfect, thanks!

  4. #4
    Registered User
    Join Date
    01-22-2015
    Location
    Colorado
    MS-Off Ver
    Windows 2010 on Windows 7
    Posts
    1

    Re: extract time from date/time for sorting

    I think this will be useful beyond this one problem. I am assuming your date is formatted like so: 01/01/2015 01:31:23 PM

    First, insert 3 columns to the right of the column with date and time. (Right-click on the column letter and click "insert.") Do you have a "Data" tab? If not, you can right-click in the blank space of the ribbon, click on "customize the ribbon" and check the "data" button from the main tabs (on the right).

    Then, select the column of data with the date and time. Then, click on the data tab on "text to columns" and that brings up a wizard. Leave delimited selected, and click next. Check only the box labeled “space” and deselect any other boxes that may be checked. Click on "Next" and "Finish." That will split the data into date column, time column, and AM/PM column. Then I changed the format of the time cells by right-clicking and clicking on format. I selected 24 hour days (i.e. military time) and sorted that way. As long as you "expand the data selection" the times will be sorted in order and it will keep the original date in the box next to it. Then you should be able to sort normally based on date, time or AM/PM, or custom sort so you have different layers to sort by, for instance, date then time.

    Good luck!

+ 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