date search

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
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
 
Back
Top