Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query the month of January for all years

Status
Not open for further replies.

jmw713

Programmer
May 6, 2004
3
US
I have a customer table, with install dates and service dates. What I am having trouble with is, I need the query to return the service date or if null return the install date. I can't seem to get them both to work.
The other issue is the numeric date for January (01) returns no values and 1 returns 1,10,11,12. I am trying to do this all from the criteria section in the query, I am new to anything else.
 
You need something like

SELECT install_date, service_date, DatePart("m";installdate), DatePart("m";service_date) FROM tblDate WHERE iif(isnull(install_date),service_date = Date,install_date = Date)

AND

SELECT install_date, service_date, DatePart("m";installdate), DatePart("m";service_date) FROM tblDate WHERE DatePart("m",install_date) = 1 or DatePart("m", service_date) = 1.

The brackets are wrong placed for sure while I'm usualy make the querys in the Access SQL grid but it give you a direction.

Greetz,
Gerard
 
First off thanks for the reply.
My problem is I am very new so alot of this makes no sense yet.
Below is the code I have which was input automatically after I enter the criteria. The only problem I have now is I cannot get the query to return records on services that were conducted in January but installed in... lets say Febuary. ie:
I have 3 customers that were last serviced in January. 2 were installed in January one was installed in Febuary. The query below only returns records for services in January and installs in January. The Febuary doesn't show.
Please help.

Thanks in advance
James


SELECT Customers.[Install Date], Customers.[Last Service Date], Customers.BillingAddress, Customers.City, Customers.StateOrProvince, Customers.PostalCode, Customers.PhoneNumber
FROM Customers
WHERE (((Customers.[Install Date]) Like "01*") AND ((Customers.[Last Service Date]) Like "01*" Or (Customers.[Last Service Date]) Is Null));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top