Are you just looking for the latest date inside the objProduct Recordset? If so, you can keep a single tracker inside the loop to find out the latest date. Try something like this:
1. Drop the objEndDate Recordset.
2. Change objSelect to objProduct
3. Add the SaleEnd column to your objProduct SQL statement
4. Change the loop like this:
Code:
Dim LatestDate
Do While Not objSelect.EOF
If objProduct("SaleEnd") > LatestDate Then
LatestDate = objProduct("SaleEnd")
End If
Response.Write objProduct("Category") & "[/b]<BR>"
Response.Write objProduct("Prod_Item") & "[/b]<BR>"
Response.Write objProduct("Price") & "<BR><BR>"
objSelect.MoveNext()
Loop
This code checks the value of the SaleEnd column. If its value is larger than the value in the LatestDate variable, the value from SaleEnd is stored in LatestDate. This way, LatestDate will always contain the, eumm, eeuh, latest date.
If SaleEnd can be null as well, you may need to do some checking and casting for this code to run properly.
HtH,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.