Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PERFORM QUERY USING A DATE FIELD

Status
Not open for further replies.

NETHROW

Technical User
Oct 18, 2002
12
US
I'M TRYING TO PERFORM A QUERY ON A (SHORT)DATE FIELD
WITH AN INPUT MASK OF 99/99/0000;0;_.

THIS IS WHAT I HAVE IN THE DATE FIELD AS CRITERIA
>&quot;«Expr»&quot;=#12/1/2002# And <=#12/5/2002#
I GET A DATA TYPE MISMATCH IN CRITERIA EXPRESSION ERROR

HOW DO I PERFORM A QUERY USING A SHORT DATE FORMAT BETWEEN 2 DATE RANGES?
 
Format(yourdate,&quot;Short Date&quot;) >= #12/1/02# And Format(yourdate,&quot;Short Date&quot;) <=#12/5/02#
 
Dates are not stored in short date form. You don't need the format command in the where clause. Post the full sql and we'll be able to straighten it out. Certainly it _is_ true that you need to list the filed twice if you have two criteria.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
&quot;Dates are not stored in short date form.&quot;
So, what does this have to do with writing some code that will do the job. Given that dates are stored as numbers, the example shown will work regardless of whether time was included in the initial insertion of the date. There are many ways to do this. If your's is better let us see the example.
 
Thanks for the input everyone, someone has suggested a solution that works fine and I thought you may want to see it.
In the criteria box, for your date in the query, type
Between [Enter 1st date] and [Enter last date]
or
Between #1/1/02# and #12/02/02#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top