How would i get the parameter field in a Dreamweaver recordset to default to the latest date in a weekending recordset?

How would i get the parameter field in a Dreamweaver recordset to default to the latest date in a recordset?

I have a table (UT_DATE) that has a ton of week ending dates.  I have the below parameter that has a default of 08/12/2012.  How do I tell the parameter to check the UT_DATE table for the last weekending (I'm assuming a date diff) and make that my default.

So my table field has dates 08/12/2012, 08/19/2012, 08/26/2012, 09/02/2012, 09/09/2012...If they viewed it now I would want it to default to  09/02/2012 (the current week)...

<%
Dim Recordset1__dt
Recordset1__dt = "08/12/2012"
If (Request.Form("WeekEndingx") <> "") Then
  Recordset1__dt = Request.Form("WeekEndingx")
End If
%>
Kevin SmithAsked:
Who is Participating?
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
A more complex option would be to create another recordset of just dates  and sort that descending order by date and choose the top 1 in your sql.  Let's call this recordset rsLastDate.

<%
theDate=rsLastDate("date") 'default to your last date
if Request.Form("WeekEndingx")<>"" then 'if the form is submitted then use that date
    theDate=Request.Form("WeekEndingx")
   if not isdate(theDate) then ' lets make sure we have good data
       theDate=rsLastDate("date")  'it was bad so lets use our orig date
   end if
end if
%>
<%
Dim Recordset1__dt
Recordset1__dt = theDate
If theDate <> "") Then 
  Recordset1__dt = theDate
End If
%>

Open in new window


You don't have to use separate tags <% but if you mix all that together, you will not be able to use the drag and drop in dreamweaver.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
The simple way is to sort your recordset by your date field in descending order.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.