Date range in criteria

K

Kathryn

I am trying to use the Max() function using =>[Enter first
date] and <= [Enter last date] as the criteria in a
query. I want the maximum date available in the table
that is between the dates entered.

Is this possible or do I have to make up two queries.
 
F

Fredg

Kathryn,
If you want the one date that is the latest in your table,
between 2 varying dates try either one of these?

SELECT DMax("[ADate]","YourTable","[ADate] Between # " & [Enter] & "# AND #
" & [End] & "#") AS MaxDate
FROM YourTable
GROUP BY DMax("[ADate]","YourTable","[ADate] between # " & [Enter] & "# and
# " & [End] & "#");

Or...

SELECT Max(YourTable.ADate) AS MaxOfADate
FROM YourTable
WHERE (((YourTable.ADate)) Between [Enter] And [End]);
 
J

John Spencer (MVP)

SELECT Max(DateField) as MaxDate
FROM TableName
WHERE DateField =>[Enter first date] AND
DateField <= [Enter last date]

If you are doing this in the query grid, then put your Datefield in the grid
three times.

Select Max for Total line for the first Datefield
Select Where for Total line for the subsequent Datefields and then enter your
criteria in the Where line.
 

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