Need to run query by month

G

Guest

I have set up a table with the fields:- Date,Part,Spec, Dept, ordered by, for
a part ordering system. I have set up queries for types of parts ordered, who
ordered, but I am unable to set up a query to give the results of parts
ordered by date, I don't want the whole date, I just want parts ordered by
month. I have tried datepart in the criteria box but without success. Please
help ! !
 
D

Douglas J. Steele

Add a computed field that returns only the month (using Month([MyDateField])
or DatePart("m", [MyDateField]) to the query, and put the month number as
the criteria for that field. You may also want to do the same using
Year([MyDateField]) or DatePart("yyyy", [MyDatePart]).

Hopefully Date isn't actually the name of the field in your table. That's a
reserved word, and using it for your own purposes can lead to problems.
 
G

Guest

Thanks Douglas for the reply,
I have tried to us
(Datepart("mm",[Datefield])) and then in the criteria =[enter month##] but
that does not seem to work. Yes I do have the first field labled "Date". any
more sugestions?

Douglas J. Steele said:
Add a computed field that returns only the month (using Month([MyDateField])
or DatePart("m", [MyDateField]) to the query, and put the month number as
the criteria for that field. You may also want to do the same using
Year([MyDateField]) or DatePart("yyyy", [MyDatePart]).

Hopefully Date isn't actually the name of the field in your table. That's a
reserved word, and using it for your own purposes can lead to problems.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



access said:
I have set up a table with the fields:- Date,Part,Spec, Dept, ordered by,
for
a part ordering system. I have set up queries for types of parts ordered,
who
ordered, but I am unable to set up a query to give the results of parts
ordered by date, I don't want the whole date, I just want parts ordered by
month. I have tried datepart in the criteria box but without success.
Please
help ! !
 
D

Douglas J. Steele

DatePart doesn't use "mm", it uses "m"

Hopefully you realized that I was using MyDateField as a generic field name:
you need to replace it with whatever your field is called. I'll repeat my
comment: you should NOT name a table field Date. If you absolutely cannot
change it, make sure you always enclose the field name in square brackets
([Date]) when you use it (and be prepared for unexplained problems!)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



access said:
Thanks Douglas for the reply,
I have tried to us
(Datepart("mm",[Datefield])) and then in the criteria =[enter month##] but
that does not seem to work. Yes I do have the first field labled "Date".
any
more sugestions?

Douglas J. Steele said:
Add a computed field that returns only the month (using
Month([MyDateField])
or DatePart("m", [MyDateField]) to the query, and put the month number as
the criteria for that field. You may also want to do the same using
Year([MyDateField]) or DatePart("yyyy", [MyDatePart]).

Hopefully Date isn't actually the name of the field in your table. That's
a
reserved word, and using it for your own purposes can lead to problems.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



access said:
I have set up a table with the fields:- Date,Part,Spec, Dept, ordered
by,
for
a part ordering system. I have set up queries for types of parts
ordered,
who
ordered, but I am unable to set up a query to give the results of parts
ordered by date, I don't want the whole date, I just want parts ordered
by
month. I have tried datepart in the criteria box but without success.
Please
help ! !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top