+ Reply to Thread
Results 1 to 7 of 7

Can't sort oldest to newest with time formula, only smallest to largest

  1. #1
    Registered User
    Join Date
    03-30-2020
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 365 Business
    Posts
    5

    Can't sort oldest to newest with time formula, only smallest to largest

    I'm having a heck of a time getting Excel to recognize a formula as a time value.

    I'm working with a list of college football games. The timestamp for kickoff comes in as ISO 8601. I have a formula that basically says:

    - If the date/time in column E is AFTER the first Sunday in November of that year, then subtract fours hours from the time.
    - If the date/time in column E is BEFORE the first Sunday in November of that year, then subtract 5 hours from the time.

    (Since UTC is 4 or 5 hours ahead depending on DST)

    It's giving me the correct value which is great, but even after wrapping it in TEXT(formula, "h:mm AM/PM") and formatting the column identically, it still only sorts smallest to largest. I've tried a few different options for formatting it but I'm stuck.

    Thanks for any help you can give.

    timeRiver.xlsx

  2. #2
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    2,832

    Re: Can't sort oldest to newest with time formula, only smallest to largest

    Maybe I'm misunderstanding something, but when I open your file, column G sorts fine - ascending and descending.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can't sort oldest to newest with time formula, only smallest to largest

    Your file is fine.

    When you have date/time values using an AutoFilter sort, you do not see "oldest to newest" you only see "smallest to largest" and "largest to smallest".

    You see the "oldest to newest" option when you do a manual sort of dates (I don't see it with times).

    Quote Originally Posted by sixseven View Post
    after wrapping it in TEXT(formula, "h:mm AM/PM") and formatting the column identically
    Yeah, don't do that. That will give you text, which will not sort properly as time.

    smallest to largest.jpg

    oldest to newest.jpg
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    03-30-2020
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 365 Business
    Posts
    5

    Re: Can't sort oldest to newest with time formula, only smallest to largest

    Interesting. I see what you mean about time not sorting. That's...annoying.

    I removed the TEXT() formatting, and changed the column formatting to "mm/dd/yy h:mm am/pm".

    Attachment 845810

    And now it sorts properly oldest to newest.

    Attachment 845809

    Is it me or it kind of nuts it doesn't read time and give an option to sort oldest to newest?

    Thanks for help Jazz.

    Attachment 845811

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can't sort oldest to newest with time formula, only smallest to largest

    Sorry, your attachments didn't work.

    There is a bug in our image attachment feature. To attach an image, first click Go Advanced under your edit box. Then click in the text to set the cursor to where you want the image to appear, then press the image icon and attach your image.

  6. #6
    Registered User
    Join Date
    03-30-2020
    Location
    Phoenix, AZ
    MS-Off Ver
    MS Office 365 Business
    Posts
    5

    Re: Can't sort oldest to newest with time formula, only smallest to largest

    I don't have a "Go Advanced" option when I edit my post. But it looks like I can add them in a new post.


    I removed the TEXT() formatting, and changed the column formatting to "mm/dd/yy h:mm am/pm".


    FormulaUpdate_ColumnFormatting.png

    And now it sorts properly oldest to newest.


    ColumnSort_PostFormattingChange.png


    Is it me or it kind of nuts it doesn't read time and give an option to sort oldest to newest?

    Thanks for help Jazz.


    jazz.jpg

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Can't sort oldest to newest with time formula, only smallest to largest

    Quote Originally Posted by sixseven View Post
    Is it me or it kind of nuts it doesn't read time and give an option to sort oldest to newest?
    As I said, when you use TEXT, the result is text, not time. So Excel doesn't know it should be "oldest to newest". Excel doesn't read the text and say, "Oh, this kinda looks like time to me." Text is text.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Auto Sort Oldest to Newest by Date
    By jakjo641 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-24-2022, 05:20 PM
  2. Unable to sort dates by oldest to newest
    By probuddha in forum Excel General
    Replies: 8
    Last Post: 06-25-2016, 08:27 AM
  3. Replies: 1
    Last Post: 04-16-2015, 06:29 PM
  4. How to change this code to sort dates from the oldest to the newest
    By bazofio in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-29-2014, 05:24 PM
  5. [SOLVED] Sort dates in column from oldest to newest...
    By ILoveYouExcel in forum Excel General
    Replies: 2
    Last Post: 06-11-2014, 02:11 PM
  6. How Sort by Largest to Smallest Column by Formula
    By termal in forum Excel General
    Replies: 10
    Last Post: 01-08-2014, 01:17 PM
  7. [SOLVED] VBA to sort columns left to right - oldest to newest
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-17-2013, 10:36 AM

Tags for this Thread

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