Query for next two dates

S

Sandspur

I need help with a select query that will select the next two (2) [duedate]
in table and return those records where [duedate] >= today
 
J

John Spencer

The SQL statement would look something like

SELECT TOP 2 DueDate
FROM YourTable
WHERE DueDate >=Date()
ORDER BY DueDate

If you can only use the query grid
Field: DueDate
Sort: Ascending
Criteria: DueDate >= Date()

Then set the query's Top Values property to 2

If you table contains multiples of the same date then you will need to build
a distinct query first and then use that in place of the table. You might
be able to do that in a single query that looks like the following in SQL.

SELECT Top 2 DueDate
FROM
(SELECT DISTINCT DueDate
FROM YourTable
WHERE DueDate >= Date()) as UniqueDates
ORDER BY DueDate

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
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