Ascending Month in Query

Unicon

Registered User.
Local time
Today, 09:52
Joined
Dec 24, 2009
Messages
123
Dear all,

My ascending order is not working in query and it's showing randomly (April 2011 and than March 2011 and than May 2011). I have a query with month and year. Please advice how can I fix it.


SELECT Format$([AttDate],"mmmm yyyy",0,0) AS [Month], QryDailyAttendance.AttendanceType AS Idle, Count(QryDailyAttendance.EmployeeID) AS [Total Idle Staffs]
FROM QryDailyAttendance
GROUP BY Format$([AttDate],"mmmm yyyy",0,0), QryDailyAttendance.AttendanceType
HAVING (((QryDailyAttendance.AttendanceType)=7))
ORDER BY Format$([AttDate],"mmmm yyyy",0,0);

Thanks in advance.
 
Try ORDER BY Month;
as you have created Month as a Field.

This still may not work however as although you have formatted Month as mmmm-yyyy, the underpinning date will be dd/mm/yy and any sort will be in Ascending order of Date. Changing the format only changes the way the date is presented, it does not change the date.

I suggest youake a look at the function DATEPART as it may do the trick for you.
 

Users who are viewing this thread

Back
Top Bottom