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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning dates that fall within range of months, irrespective of year

Status
Not open for further replies.

djtizzlemaster

Programmer
Mar 5, 2008
17
0
0
US
I want to return records where the value for the Birthday column falls in the month of March, April, or May, irrespective of the year.

Here's the criteria I'm using:

Code:
DatePart("m", [SalesDate]) = 3
DatePart("m", [SalesDate]) = 4
DatePart("m", [SalesDate]) = 5

Now when I run the query, it asks me to Enter Parameter for "SalesDate." I don't know what this means, so I just typed in today's date. Then the query ran but it did not filter the results according to my criteria!

I have very little experience with Access, so please explain to me - plain and simple - why the criteria aren't working and what SalesDate is all about!
 
What is your actual SQL code ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This isn't web-based at this point.. just trying to get this to work on my local machine.

Did I post this in the wrong forum?
 
Code:
DatePart("m", [SalesDate]) = 3
DatePart("m", [SalesDate]) = 4
DatePart("m", [SalesDate]) = 5

Sorry if I created any confusion by putting this in a code box.. these are just the queries that I entered into the Access GUI.
 




Select the SQL View (like Design View) and post the SQL Code, please.

Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
Code:
SELECT Customers.[FIRST NAME], Customers.[LAST NAME], Customers.BIRTHDAY, Customers.BIRTHDAY2, Customers.BIRTHDAY3, Customers.BIRTHDAY4, Customers.BIRTHDAY5
FROM Customers
WHERE (((DatePart("m",[SalesDate]))=3 And (DatePart("m",[SalesDate]))=3 And (DatePart("m",[SalesDate]))="3" And (DatePart("m",[SalesDate]))="3" And (DatePart("m",[SalesDate]))="3")) OR (((DatePart("m",[SalesDate]))=4 And (DatePart("m",[SalesDate]))=4 And (DatePart("m",[SalesDate]))="4" And (DatePart("m",[SalesDate]))="4" And (DatePart("m",[SalesDate]))="4")) OR (((DatePart("m",[SalesDate]))=5 And (DatePart("m",[SalesDate]))=5 And (DatePart("m",[SalesDate]))="5" And (DatePart("m",[SalesDate]))="5" And (DatePart("m",[SalesDate]))="5"));
 




assuming that you have a REAL DATE...
Code:
Where Month([YourDateField]) IN (3,4,5)

Skip,
[sub]
[glasses]Have you heard that the roundest knight at King Arthur's round table was...
Sir Cumference![tongue][/sub]
 
Why do you have 5 birthday fields? Are they all date data types?

Why do you sometimes place quotes around the month number and sometimes not?
(DatePart("m",[SalesDate]))=4 And (DatePart("m",[SalesDate]))="4"

Where does the SalesDate come from? Is it in the Customers table?

Do you want to search and match any one of the birthday fields?

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top