View Full Version : Finding the second to last date in a table.


piersonb
10-22-2009, 04:06 PM
I have a query setup to look at a table of transactions.
I have a second table with a list of dates.

I am trying to set up my first query to show me the transactions between the last date and the second to last date.

my table of dates is enter sequantial and I am using DLast to get the last date. any ideas on how to get the second to last date?

I currently have this statement in my Criteria:
Between [Enter Second to last date] And DLast("Last_date","date_update_table")

Galaxiom
10-22-2009, 06:21 PM
Use DMax rather than DLast. Tables are unordered and the last is the last record not necessarily the most recent. Similarly use DMin rather than DFirst.

For the second to last:
DMax("Last_date","date_update_table","Last_date<>DMax('Last_date','date_update_table')")

piersonb
10-23-2009, 08:31 AM
Thank you. I had set the table up so that when a new date was added it would be required to be later then the last date but I like this idea better.