How do I.....

Results 1 to 3 of 3

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

    Assuming scalability is not a big factor, you could count the result using Count(ColName) where date1&#060;=datevar1 and data2&#062;=datevar2. Now generate a random number between 1 and your count. Then, using the same statment but without count, display the rows but use an if then statement such as if counter=randcount then%&#062; and then display the data. This will return one random of the selected number. Again, this is not the best way to do it resource wise, but it will work for most applications.<BR><BR>Good Luck<BR><BR>Brandon

  3. #3 Guest

    Default RE: How do I.....

    Here&#039s some clues:<BR><BR>The SQL would look something like this ...<BR><BR>SELECT * FROM TABLE WHERE (FIELD&#062;=#Date1# AND FIELD&#060;=#Date2#)<BR><BR>The random record would look like this ...<BR><BR>Randomize<BR>varInt=Recordset.Recordcou nt<BR>Recordset.Move (Int(Rnd(varInt)*varInt)+1)

Posting Permissions

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