Latest values

G

generallevy

Hi ive set up a query to gather some information from a single table. I'd
like to take a snapshot of the latest entries in the database. All the data
is entered at 5 minute intervals.. Under criteria is there a way to specify
the latest entry so if the querys run at 06:00:01 it will take the entry at
06:00:00, if its run at 07:59:05 it will take 07:55:00 etc - the objective is
to get an update of the latest entries.
Thanks
 
G

generallevy

Thanks Karl,
This is the SQL -

SELECT HistoryLog.GENSETNAME, HistoryLog.ItemDATE, HistoryLog.ItemTIME,
HistoryLog.Pwr
FROM HistoryLog;

Ive tried what you recommend but it returns blank because the dates are
abnormal - for example the last entry for one GENSETNAME may be 01/02/2009
whereas another one is 03/02/2009 another may be 10/03/2009. In the most
they are logged ewvery five minutes but they are often offline and not
logging at all for days or weeks - when this happens I need to pick up the
last entry in the output.

Thanks
 
J

John Spencer

It is unclear whether you want a specific number of records (1) or a
specific time frame. Assuming that you want the latest record there are
two methods.

SELECT TOP 1 *
FROM YourTable
ORDER BY EntryDateTime DESC

or

SELECT *
FROM YourTable
WHERE EntryDateTime =
(SELECT Max(EntryDateTime)
FROM YourTable)

If you don't know how to use the SQL window, post back with a step by
step on how to build the query in the query design window. It would be
helpful if you posted at least the name of the table and the name of the
datetime field(s).

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

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