Parameter to Select Year in Date column

K

Kaylen

I have a date column or date field in my database, I want to create a select
Query in which the Parameter asks to enter in a person's last name and the
year; then the query would show all data with the year wanted for the wanted
person. For example, I want to run a query of all the transactions taken
place in 2008 for this specific person last name. I am able to set the
parameter to ask for the last name, but I dont know how to set the parameter
for the year. Date field format is short date --/--/----. Can someone help me
set the parameter in the query to select all dates within one specific year?
Any help is appreciated.
 
J

John Spencer

I would use something like

Between DateSerial([What Year?],1,1) and DateSerial([What Year?],12,31)

Assumption: Your field is a date field and you are only storing the dates and
not dates and times. If you store times the above will give you all records
up to midnight of Dec 31, but any record for the remainder of Dec 31 will not
be shown.

So for real safety the criteria becomes
TransactionDate >= DateSerial([What Year?],1,1) and TransactionDate <
DateSerial([What Year?]+1,1,1)


John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 

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