Report filtered by date

P

Phil

Hi,
I have a report that has a date field (named Date) in it and I want to
filter the report selecting only records that have a date before 7/1/08. In
the Report filter I have tried to ented an expression, but nothing I try
seems to work. I thought that [Date] < 7/1/2008 would work, but it didn't.
Everything I tried gives me an "Expression" error.
Can some one tell me the correct syntax? My field Date is a "Date/time"
Data type.
Thanks
 
J

John Spencer

First of all DATE is a bad choice for a field name. Date is also a
function that returns (or sets) the system date.

Try
[Date] < #2008-07-01#

Please note that date literals must use the # as a delimiter and date
literals must be in US format mm-dd-yyyy or in the unambiguous
yyyy-mm-dd format.

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

Dale Fye

Is 7/1/2008 a firm date that will be used every time the query is run, or
are you actually using a parameter query, and want to be able to change that
date. If you are trying to do a parameter query, then the criteria would
look something like:

WHERE [Date] < [Enter date]

and I would declare the parameter [Enter date] as a date/time data type. If
you do that, you won't have to wrap it in the # symbols, as John mentioned.
The way to declare a parameter is to right click in the top portion of the
query grid. Click on the Parameters option, then, in the Parameters dialog
box, enter the name of the parameter (along with the [ ] brackets) in the
left most column, and select Date/Time from the right most column.

HTH
Dale
 

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