How do I sort a date by the month instead of the year?

  • Thread starter Thread starter Bo
  • Start date Start date
B

Bo

I need to sort a date field by month instead of the year.
Basically, the year is a "don't care". I am trying to use
the criteria in the query design for the "Birthday" field
but nothing seems to work. I'd appreciate any assistance
you can provide.
 
You can use the DatePart() function to return the month
part of a date, or possibly better for your case, the day
of the year, and then sort by that field. You should be
able to find help for this function in Access help, but
following are some examples:

DatePart("m",[YourDateField])
....will return the month

DatePart("y",[YourDateField])
....will return the day of the year

HTH, Ted Allen
 
Dear Bo:

You could use:

ORDER BY MONTH(YourDate), DAY(YourDate)

To do this in the query grid, create non-displayed calculated columns:

MONTH(YourDate)
DAY(YourDate)

and set them up to sort.

Tom Ellison
Microsoft Access MVP
Ellison Enterprises - Your One Stop IT Experts
 
Hi,
I am extracting a query and I want to make the query that sum all data by
weekly, for all year 2003, and my data is entred in daily basis. I
appreciate assistances.

Thank you all in advance your assistance.

Furmoly
Ted Allen said:
You can use the DatePart() function to return the month
part of a date, or possibly better for your case, the day
of the year, and then sort by that field. You should be
able to find help for this function in Access help, but
following are some examples:

DatePart("m",[YourDateField])
....will return the month

DatePart("y",[YourDateField])
....will return the day of the year

HTH, Ted Allen
-----Original Message-----
I need to sort a date field by month instead of the year.
Basically, the year is a "don't care". I am trying to use
the criteria in the query design for the "Birthday" field
but nothing seems to work. I'd appreciate any assistance
you can provide.
.
 
Hi,
I am extracting a query and I want to make the query that sum all data by
weekly, for all year 2003, and my data is entred in daily basis. I
appreciate assistances.

Thank you all in advance your assistance.

You might do better to post a new question, rather than replying to
someone else's thread! Most of the volunteers won't bother to open a
thread that seems to already have replies - I just did so by chance.

Assuming you have a date/time field, you can create a calculated field
by typing

WeekNo: DatePart("ww", [datefield])

in your Query. This will give the week number, from 1 to 54 - see the
VBA online help for DatePart to learn about the optional arguments
defiing what's meant by "the first week of the year".

This field can be used for sorting, searching, or grouping as you
wish.

John W. Vinson[MVP]
(no longer chatting for now)
 
Back
Top