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

Query to retrieve the most recent Record 1

Status
Not open for further replies.

Pistol

MIS
Jan 29, 2001
59
US
I need to get a "Last Modified: XX/XX/XX" displayed on an ASP file that generates a table containing results from a database. Because this isn't possible in the current version of Active Service Pages I have decided to query the database to display the information I want.

Example: When a user updates the database (via a form
HTML:
) a "date submitted" ( date() ) is recorded with the record in the same table. I then came up with a query to retrieve the most recent record submitted to the database, the SQL statement is as follows:

**********************************************************
SELECT Last(JobOpenings.DateSubmitted) AS LastOfDateSubmitted
FROM JobOpenings;
**********************************************************

I then display the results on the webpage just beside the statement "Last updated on" ******" That works fine. The issue lies in the query. Thes query does in fact select a record, but it is four days old,  

Anyone have any suggestions?
Thanks in advance
 
Try using Max instead of Last:

SELECT Max(DateSubmitted) AS LastOfDateSubmitted
FROM JobOpenings;

However, if you are using the Date() function, won't there be multiple records with the same date? You should use the Now() function instead of Date(), this will return the date and time. Make sure the field in your table has a general date format to receive the date and time.

Now use the Max() function, and you will get the record with the latest data.

Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top