Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / February 2008

Tip: Looking for answers? Try searching our database.

Query for next two dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sandspur - 11 Feb 2008 09:26 GMT
I need help with a select query that will select the next two (2) [duedate]
in table and return those records where [duedate] >= today
John Spencer - 11 Feb 2008 12:27 GMT
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

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

>I need help with a select query that will select the next two (2) [duedate]
> in table and return those records where [duedate] >= today
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.