Results 1 to 3 of 3
  1. #1
    kaledev is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    20

    Question Sorting by date

    I am having an issue with a query. It is returning dates that have been formatted in mmm 'yy format, meaning Jan '11, Feb '11, and so on.



    For whatever reason when sorted it relies on A-Z instead of Newest to Oldest and so on. Jan '11 is being displayed first, then Jan '10, then Feb '11, Feb '10...

    I need this to be sorted like a regular date field, containing '11 data first, then '10. I tried using the Format function:

    Code:
    Format([Month], "yyyy-mm-dd")
    And it just spits out Jan '11 again like I didn't do anything. Is there some sort of trick to sorting dates in mmm 'yy form? I have to keep them in mmm 'yy form unfortunately, otherwise I would change them all to normal dates. Thanks!

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    Add another column with the date in the correct format and sort on that instead.

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what is your code in the ORDER BY clause? It shouldn't do that naturally.

    for instance, this code should work fine:
    Code:
    SELECT format(datefield, "mmm yy")
    
    ORDER BY datefield
    if you're ordering by the format itself, or by the alias name you've assigned to the expression, it will probably do what its doing, because the expression starts with an alpha, not a number. Moreover, the expression, which I believe is automatically assigned to an alias field name, is not the datefield.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 9
    Last Post: 01-28-2011, 06:05 PM
  2. Sorting date columns in query
    By madcreek in forum Queries
    Replies: 3
    Last Post: 06-02-2010, 07:45 AM
  3. Date Sorting
    By sfoot0309 in forum Queries
    Replies: 1
    Last Post: 04-25-2010, 09:59 PM
  4. Sorting by date between different groupings
    By wagspk in forum Reports
    Replies: 0
    Last Post: 03-11-2009, 11:53 PM
  5. Sorting By Date!
    By Pirate in forum Access
    Replies: 0
    Last Post: 07-19-2007, 02:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums