date search

G

Guest

Hi


I’m drawing a blank here today. I would think this should be easy but I
can’t figure it out. I have a date field for driver license expiration. I
want to create a query so that the user can just enter the month and year and
get all the licenses that expire that month.


Thanks
Chuck
 
O

OfficeDev18 via AccessMonster.com

Hi, Chuck,

SELECT * FROM YourTableName WHERE Month(ExpirationDateField) = [Enter Month]
AND Year(ExpirationDateField) = [Enter Year];

The query will prompt the user to "Enter Month" (response is 1 thru 12) and
"Enter Year" (response can be either 2 or 4 numbers) and will display all
fields for all records with those parameters.

Hope this helps,

Sam
 
G

Guest

Sam

It prompts me for the month and year but no data shows in the query

here is what I put in the select query

SELECT *
FROM tblMain
WHERE Month(InsExpDate)=[Enter Month] And Year(InsExpDate)=[Enter Year];

my field in tblMain is called InsExpDate and is a Date/Time field formated
as shortdate with a short date input mask
 
G

Guest

Sam

Never mind my last post it works great, it only accepts a 4 digit year
which was why no data was comming up.

Thank you very much.
Chuck
 
O

OfficeDev18 via AccessMonster.com

Chuck,

When it prompted you for month and year, what did you input?

By the way, I imagine you're running this in the query designer, and
displaying it in datasheet mode.

Sam
Sam

It prompts me for the month and year but no data shows in the query

here is what I put in the select query

SELECT *
FROM tblMain
WHERE Month(InsExpDate)=[Enter Month] And Year(InsExpDate)=[Enter Year];

my field in tblMain is called InsExpDate and is a Date/Time field formated
as shortdate with a short date input mask
[quoted text clipped - 5 lines]
Thanks
Chuck
 

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