View Full Version : How to pickup latest date from database

Squall Leonhart
11-21-2003, 07:51 PM
Hi, guys.

Do you know how to pick up latest date from database?
Please take a look at following code.

Dim adoCon
Dim rsRequest
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection")
Set rsRequest = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT date FROM tblRequest"
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tech_re.mdb")
rsRequest.CursorType = 3
rsRequest.Open strSQL, adoCon
<table width=100% topmargin=0>
<TR valign=top>
<TD colspan=2 align=center ><FONT FACE=Arial,Helvetica SIZE=2 color=blue><B>TOP 10 IT HOTLIST</b></font></td>
<TD colspan=2 align=center WIDTH=300><FONT FACE=Arial,Helvetica SIZE=-1 color=blue><i>Last modified:<%=rsRequest("date")%> </i></font></td>
<TD WIDTH="300" ALIGN=LEFT><FONT FACE=Arial,Helvetica SIZE=-1 color=red><B> <a href="ITHotlist.xls" target=new>All IT Projects...</a></B></FONT></TD>
<%'Reset server objects
Set rsRequest = Nothing
Set adoCon = Nothing


It's not picking up newest time. It's only picking up first one.
So what can I do?

11-21-2003, 08:05 PM
select max(date) from .....

Roy Sinclair
11-21-2003, 08:09 PM
SELECT Max(date) FROM tblRequest -- Is how I'd do that.

Edit: Got distracted by an article that came in my email so Roelf beat me to it :p.