p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: date field in a query


Message #1 by "Brent Mills" <bmills@a...> on Wed, 12 Jun 2002 15:39:17
I was wondering if it is possible to insert a variable into a date field 
in a query.  For instance, I want to query all records for the month of 
May but I want to insert a year value that is from a table.  Is there any 
way to do this?
Message #2 by "Gerald, Rand" <RGerald@u...> on Wed, 12 Jun 2002 10:03:59 -0500
Here is one way to do it - SQL version:

SELECT tblMyTable.ID, tblMyTable.MyDate, tblMyTable.Other
FROM tblMyTable
WHERE (((Year([MyDate]))=3D[Select Year]) AND 
((Month([MyDate]))=3D[Select
Month]));

This uses parameters for Select Year and Select Month, but variables 
could
be substituted for the parameters.

Obviously, your table and field names may be different.

Rand E Gerald
Database Specialist
Information Services / Operations
Bah=E1'=ED National Office
1233 Central St.
Evanston IL 60201
(xxx) xxx-xxxx

-----Original Message-----
From: Brent Mills [mailto:bmills@a...]
Sent: Wednesday, June 12, 2002 10:39 AM
To: Access
Subject: [access] date field in a query

I was wondering if it is possible to insert a variable into a date 
field
in a query.  For instance, I want to query all records for the month of
May but I want to insert a year value that is from a table.  Is there 
any
way to do this?
Message #3 by "Brent Mills" <bmills@a...> on Wed, 12 Jun 2002 16:22:28
Thanks a bunch, I wish Access's help file documented things like that more 
often.

  Return to Index