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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

top 10 selection ... (Not a quickie)

Status
Not open for further replies.

callhandler

Programmer
Oct 25, 2002
11
US
I have a list of dates ...

The date field has data in the format:
mm/dd/yy hh:mm (ie it has time as well)

I want a query to select the 10 most recent days.

This sounds easy to me ... but I can't break it on one query!
 
Add a new field to your query
MyTopDate:Format([DateField],"mm/dd/yy")
then sort this field decending. Then select the Top 10 from the Top dropdown box on the toolbar. It's the one with the word "All" usually showing.

Paul
 
The default for date arithmetic is days so comparing to the current date -10 should do it.


select DateField from yourtable
where Format([DateField],&quot;mm/dd/yy&quot;) <= (now() -10)
 
thanks for the last post, but i do not necessarily have continuous dates, so it's useful, but not the answer....
the earlier response solves the problem!
 
Okay, the top 10 works well for the 10 most recent records not necessarily the 10 most recent days depending on if there are multiple records on a given day.

 
>> Add a new field to your query
>> MyTopDate:Format([DateField],&quot;mm/dd/yy&quot;)
>> then sort this field decending.

surely you meant to say yy/mm/dd

otherwise you'll have nothing but grief in january

:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top