Results 1 to 8 of 8
  1. #1
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112

    Sorting of dates no working?

    Hi, I have a query that lists 3 columns:

    Name, Amount Paid, Date

    I sort by Name first, then by Date (Formatted as "mmm yyyy") but the results do not display the records sorted according to date as I expected.

    This is the SQL code:

    Code:
    SELECT [tblMainStudentInfo].[First Name] & " " & [tblMainStudentInfo].[Last Name] AS Name, tblFeesPaid.AmountPaid, Format([MonthPaid],"mmm yyyy") AS MonthYear
    FROM tblMainStudentInfo INNER JOIN tblFeesPaid ON tblMainStudentInfo.PrimaryKey = tblFeesPaid.fkStudentID
    ORDER BY [tblMainStudentInfo].[First Name] & " " & [tblMainStudentInfo].[Last Name], Format([MonthPaid],"mmm yyyy");
    The results show:
    Clare Chang $180.00 Apr 2011
    Clare Chang
    $180.00 Feb 2011
    Clare Chang
    $180.00 Jan 2011
    Clare Chang
    $180.00 Mar 2011

    I expected records to be sorted as:
    Jan 2011
    Feb 2011


    Mar 2011
    Apr 2011

    Anyone knows why? Thanks.

  2. #2
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    It's sorting in alphabetical order based on the Month name. You could include a field showing the numerical month and sort on that.

  3. #3
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112
    Ah..thanks, got it. I'm using this query to create a crosstab query, in order to make a report.

    I would like the report to be sorted according to the month/year but I would like the display to be Jan 2011 instead of 1/1/2011.

    Is there a way to accomplish this? Thank you.

  4. #4
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    Quote Originally Posted by Buakaw View Post
    Ah..thanks, got it. I'm using this query to create a crosstab query, in order to make a report.

    I would like the report to be sorted according to the month/year but I would like the display to be Jan 2011 instead of 1/1/2011.

    Is there a way to accomplish this? Thank you.

    Include both the numerical month format and the MMM format. Display the MMM format, but hide and sort the report by the numerical format.

  5. #5
    thhui is offline Competent Performer
    Windows XP Access 2002
    Join Date
    Feb 2009
    Posts
    235
    The MonthPaid field should be a datefield so that it would be sorted by date correctly.
    The display could be formated in the query window's field column's property format field instead.
    For example change it to "mmm yyyy"

    Then it will be sorted under date order and displayed in "mmm yyyy" format.

  6. #6
    William McKinley is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    59
    Quote Originally Posted by thhui View Post
    The MonthPaid field should be a datefield so that it would be sorted by date correctly.
    The display could be formated in the query window's field column's property format field instead.
    For example change it to "mmm yyyy"

    Then it will be sorted under date order and displayed in "mmm yyyy" format.

    You learn something new every day!

  7. #7
    Buakaw is offline Absolute novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    112
    Quote Originally Posted by thhui View Post
    The MonthPaid field should be a datefield so that it would be sorted by date correctly.
    The display could be formated in the query window's field column's property format field instead.
    For example change it to "mmm yyyy"

    Then it will be sorted under date order and displayed in "mmm yyyy" format.
    Hi thhui,
    Thanks very much! What you described works perfectly for a normal query. However, how do you do this in a crosstab query? I cannot find a way to format this column in Properties when it's a crosstab query. Thanks!

  8. #8
    lvh519 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Houston
    Posts
    4
    Quote Originally Posted by William McKinley View Post
    Include both the numerical month format and the MMM format. Display the MMM format, but hide and sort the report by the numerical format.
    **deleted question** I figured it out. Thanks.
    Last edited by lvh519; 02-15-2012 at 01:36 PM. Reason: I found my answer.

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

Similar Threads

  1. Sorting by date
    By kaledev in forum Queries
    Replies: 2
    Last Post: 03-16-2011, 12:32 PM
  2. display all dates between two dates
    By KenThompson in forum Access
    Replies: 8
    Last Post: 02-23-2011, 01:11 PM
  3. Mixed dates - show only complete dates?
    By weeblesue in forum Queries
    Replies: 3
    Last Post: 10-27-2010, 02:15 PM
  4. Sorting in a Query (Dates)
    By JohnS in forum Queries
    Replies: 2
    Last Post: 10-23-2009, 03:51 AM
  5. Need Sorting Help
    By rbpd5015 in forum Access
    Replies: 1
    Last Post: 09-28-2009, 07:39 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