Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 357
  • Last Modified:

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
%>
0
Kevin Smith
Asked:
Kevin Smith
  • 2
1 Solution
 
Scott Fell, EE MVEDeveloperCommented:
The simple way is to sort your recordset by your date field in descending order.
0
 
Scott Fell, EE MVEDeveloperCommented:
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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now