How do I.....

Results 1 to 2 of 2

Thread: How do I.....

  1. #1
    Joshua Mann Guest

    Default How do I.....

    I have a SQL database, I need to pull all the entries into a recordset that fall in between user specified dates. Then I need to pick a random entry from the recordset and display it. How can I do this? Please help if you can...Thank You.

  2. #2
    Join Date
    Dec 1969

    Default RE: How do I.....

    1. get all records between the specified dates (using a select statement like this..<BR>select field1, field2 from table<BR>where table_date between startdate and enddate<BR><BR>you will have to take these two values from the form using either request.form or session variables or hidden input of HTML.<BR><BR>2. from the recordset just created, get the number of records using recordcount property of recordset.<BR><BR>3. use the random function of vbscript to generate a random number. It would be something like this:<BR><BR>dim n<BR>n = rs.recordcount<BR>dim r<BR>r = Cint(n * rnd()) -- I&#039ve used Cint to get a whole number back.<BR><BR>4. use this r as the index of the recordset for returing a rendom record.<BR><BR>You might need some changes to go in here before it can exactly work for you.<BR><BR>Let me know if it worked.<BR><BR>Sandy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts