Discussion Locked
0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have a date field of dd/mm/yy which I would like to sort. I would like to sort it by the month, but when I do a sort form within a query it always sorts by the year. can anyone suggest to sort by the month.
6 replies
by exjc
In the query you wish to sort by add a column that uses the Month() function so it looks like this:
Month: Month(MyDateField)
Where MyDateField is the name of the date field you want to sort by. This puts only the number of the month from the datefield so you can use the sort criteria to sort it (acsending or descending) while excluding the year.
by roc180
Use the DatePart(interval,date) function from within your Order By to sort the data by month. The following SQL will accomplish what you want:
SELECT dt
FROM Table1
ORDER BY DatePart("m",[dt]);
Good Luck
Neal Martinelli
by kiwimac
Poster rated this answer
by kiwimac
This question was closed by the author
This discussion is closed to new replies.
Trending Software posts
Sort by Trending
0 helpful
1 reply
0 helpful
0 replies
1 helpful
1 reply
Question Unanswered
How Are Teams Testing AI-Generated Code Before Production?
0 helpful
0 replies
0 helpful
5 replies