If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Question about Query - Using Dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-14-11, 10:16
dlester dlester is offline
Registered User
 
Join Date: Jul 2011
Posts: 11
Question Question about Query - Using Dates

Hi Everyone,

I was hoping you could point me in the right direction. I have a query that is setup to ask the user for the criteria of a birth date, in the hopes that the user can query the database for all the birthdays in that table that is like the date entered. So lets say that there are 4 DOB entries in the table, 1/17/1930, 4/28/64, 4/7/59, and 3/4/77. I want to be able to search for all the April Birthdays using the query I've created. Can anyone point me in the right direction?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 07-14-11, 10:21
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Code:
SELECT ...
  FROM ...
 WHERE MONTH(dob) = 4
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 07-14-11, 10:23
dlester dlester is offline
Registered User
 
Join Date: Jul 2011
Posts: 11
Quote:
Originally Posted by r937 View Post
Code:
SELECT ...
  FROM ...
 WHERE MONTH(dob) = 4
So here replace the ... with the table name and field name, but on the where = 4 is can that be a prompt for a search by the end user?
Reply With Quote
  #4 (permalink)  
Old 07-14-11, 10:31
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by dlester View Post
can that be a prompt for a search by the end user?
Code:
WHERE MONTH[dob] = [ Enter month number 1 - 12 ]
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 07-14-11, 16:55
dlester dlester is offline
Registered User
 
Join Date: Jul 2011
Posts: 11
Quote:
Originally Posted by r937 View Post
Code:
WHERE MONTH[dob] = [ Enter month number 1 - 12 ]
Ok, I've tried this a few times and I'm not getting any result. I have some DOB's in the AgentDOB field, and all that data is stored like this:

4/1/84
10/7/63

So in this case I used the Where statement like this in the Criteria area of the Query Design View:

"Where"=[Enter Month (Use Number)]

So when I run the query, the system asks for the criteria, I put 4, and it comes back with no results. So I tried 10, same result. Am I missing something?
Reply With Quote
  #6 (permalink)  
Old 07-14-11, 19:55
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
what is the datatype of the agentdob column?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #7 (permalink)  
Old 07-17-11, 23:11
dlester dlester is offline
Registered User
 
Join Date: Jul 2011
Posts: 11
Quote:
Originally Posted by r937 View Post
what is the datatype of the agentdob column?
It is a Date/Time field
Reply With Quote
  #8 (permalink)  
Old 07-18-11, 00:16
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
It should be:
Code:
WHERE MONTH([dob]) = [ Enter month number 1 - 12 ]
__________________
Have a nice day!
Reply With Quote
  #9 (permalink)  
Old 07-18-11, 02:57
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
oh, man

i had the correct answer in post #2 and then messed it up in post #4
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Tags
access, date, query

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On