+ Reply to Thread
Results 1 to 7 of 7

Trying to sort dates to include a range of dates

  1. #1
    Registered User
    Join Date
    08-25-2017
    Location
    At, Home
    MS-Off Ver
    2016
    Posts
    5

    Trying to sort dates to include a range of dates

    Hi there.

    I'm trying to categorize some data for work and some of the documents I need to categorize have a single date (ex: 8/24/2017) while others use a range of dates (ex: 8/10/2017 - 8/17/2017).

    As of right now, my data is in a table so that I can sort between dates, document title, and document number. But when I sort by date, it doesn't go in chronological order because of the dates that include ranges; these are placed at the end. How can I use the filter to sort dates with ranges in them?

    Edit: I tried to attach a sample .xlsx but the forum wouldn't let me. Every time I clicked the attachment button only a blank drop down menu would pop up. I tried making a table using the forum's tools. Hopefully this will be good enough.

    Current
    Date Description Problem
    6/30/2014 Normal Date No Problems
    8/12 Unknown Year The year is unknown but Excel uses current year
    6/21/2014 - 7/2/2014 Date is a range Excel doesn't grab the date (want to use the first date in the range)
    7/8 Unknown Year Note: See Desired table

    Desired
    Date Description Notes
    6/21/2014 - 7/2/2014 Date is a range First date in the range is selected for sorting
    6/30/2014 Normal Date No problems
    7/8 Unknown Year Excel puts entries with unknown years at the end
    8/12 Unknown Year Excel sorts entries with unknown years by mm/dd

    Edit 2: I'm really close to getting this document done! I came across a new problem though. To get the dates with no years to appear at the end when sorted, I wrote "3000" as the year. Unfortunately, some of the date ranges have an unknown year. I can't format them to just show m/d (ex: 7/12 - 7/30) without Excel automatically changing the year to 2017. Is there a way to format the cells with unknown years to just show m/d and keep the year as "3000"? It's not too big a deal; the document works perfectly fine as is. It would only look nicer if the ranges didn't show the year "3000".
    Last edited by ehh-cellent; 08-30-2017 at 04:58 PM. Reason: added a sample

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Trying to sort dates to include a range of dates

    Hi ehh (Canada??), welcome to the forum! You could use the following formula in a separate column (which must be formatted as Date)
    Assuming dates in column B, it extracts the first date if a date range is found, else it returns the column B value unchanged.:
    Please Login or Register  to view this content.
    Paste in row 2 and copy down. Now you can filter on the new column...
    Last edited by leelnich; 08-25-2017 at 01:09 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  3. #3
    Registered User
    Join Date
    02-02-2010
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2016
    Posts
    48

    Re: Trying to sort dates to include a range of dates

    How about creating a new column which holds either a single date or, when you have a range, the last date of that range. For example, if you have cell A1 containing 8/8/2017 - 9/9/2017, you would return 9/9/2017.

    Use SEARCH to find where the middle hyphen is,
    Use LEN to find the total length of your date range string,
    Use RIGHT to pick up the string containing the last date, i.e. 9/9/2017
    And finally, use DATEVALUE to create a proper date.

    Combining all these together, the formula would be:

    =DATEVALUE(RIGHT(A1,LEN(A1)-(SEARCH(" ",A1)-1)-2))

    Hope this helps!

  4. #4
    Registered User
    Join Date
    08-25-2017
    Location
    At, Home
    MS-Off Ver
    2016
    Posts
    5

    Re: Trying to sort dates to include a range of dates

    Thanks guys for the helpful formulas!

    I have to figure out a way to tweak my data a little because some of the dates have unknown years and when I use the formula, Excel adds 2017 as the date. Still, it's a start!

    Also, my name was supposed to sound like Mr. Burns from The Simpsons saying "Excellent" but I couldn't figure out how to phonetically spell that out. :P

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Trying to sort dates to include a range of dates

    You know, a look at some representative data would help us to solve your problem quickly and accurately. The simplest thing would be to upload a sample workbook (NOT a picture). Remove any sensitive or extraneous stuff, but include examples of any "strange" data the formula must deal with ... and perhaps simulate some results to demonstrate what you want.

    To attach a workbook:
    Click Edit Post (or just start a new reply.)
    Click Go Advanced
    Scroll down to Manage Attachments and click.
    Now just Browse for your file, then click Upload. Simple!
    Last edited by leelnich; 08-26-2017 at 09:35 PM.

  6. #6
    Registered User
    Join Date
    08-25-2017
    Location
    At, Home
    MS-Off Ver
    2016
    Posts
    5

    Re: Trying to sort dates to include a range of dates

    I tried to attach a sample .xlsx document but I couldn't. I've created two tables using the forum tools instead. Hope this works!

  7. #7
    Registered User
    Join Date
    08-25-2017
    Location
    At, Home
    MS-Off Ver
    2016
    Posts
    5

    Re: Trying to sort dates to include a range of dates

    =IFERROR(DATEVALUE(LEFT(B2,SEARCH("? -",B2))),B2)
    I tried using leelnich's formula on my table but the formula automatically fills up the whole table. This means that it fills out rows I don't have any data in so when I sort from oldest to newest, there's an infinite amount of rows labeled "1/0/1900". Is there a way I can use this formula without it automatically filling out the entire table?

    Edit: Never mind, I figured out that my table size was set for $A:$E. I resized it to only have the number of rows I need and it works perfectly now!
    Last edited by ehh-cellent; 08-28-2017 at 05:16 PM.

+ 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. Replies: 4
    Last Post: 02-17-2015, 08:15 AM
  2. Replies: 1
    Last Post: 09-14-2014, 02:10 PM
  3. Check dates in range either same dates or different dates by formula
    By breadwinner in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-12-2013, 07:42 AM
  4. Replies: 18
    Last Post: 03-24-2013, 04:20 PM
  5. [SOLVED] Sorting dates:How do I sort a column filled with dates by Month, Day, then Year?
    By Heather in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-22-2005, 10:05 PM
  6. [SOLVED] Excel trying to sort list by a range of dates
    By magspc in forum Excel General
    Replies: 3
    Last Post: 03-22-2005, 10:06 AM
  7. [SOLVED] How do I get Excell to sort dates that range from 1800 to 1900's
    By Smith295 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-22-2005, 03:06 PM

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