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

Posted on 2012-08-29
Last Modified: 2012-10-31
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
Question by:Kevin Smith
    LVL 52

    Expert Comment

    by:Scott Fell, EE MVE
    The simple way is to sort your recordset by your date field in descending order.
    LVL 52

    Accepted Solution

    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
       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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now