Question about selecting record by date...

Results 1 to 3 of 3

Thread: Question about selecting record by date...

  1. #1
    Jb Guest

    Default Question about selecting record by date...

    Hello. I have a view.asp page that displayes records from a db.<BR><BR>I wanted to code something like:<BR><BR>SQL=Select * FROM Tablename Where Date is 3 weeks ago from today<BR><BR>today can = strnow<BR><BR>Can I create a var that is = to 3 weeks ago from today?<BR><BR>Such as<BR><BR>&#060;%<BR>Dim threeweks<BR>strthreweeks=Date-3weeks<BR>%&#062;<BR><BR>And Then I can sql it to view ONLY RECORDS from 3 days ago?<BR><BR>in other words, how in the world can I display records that are inserted 3 weeks ago? The &#039date&#039 column by default will have the current date of submission so I just want to view records that are 3 weeks old.<BR><BR>Is that possible?<BR><BR>Thanks

  2. #2
    Jason Guest

    Default RE: Question about selecting record by date...

    This is a snippet from one of my pages. You will need to pull out what you need. This displays everything that was entered up through "21" days ago.<BR><BR>dim ors9<BR>Dim myStartDate <BR>dim myEndDate <BR>Dim mySqlDate<BR>myEndDate = Date()<BR>myStartDate = DateAdd("d", -21, myEndDate)<BR>set ors9=server.CreateObject("ADODB.Recordset")<BR>sql txt = "SELECT * FROM table where DateJoined BETWEEN #" & myStartDate & "# AND #" & myEndDate & "# ORDER by DateJoined DESC;" <BR>ors9.Open sqltxt, "DSN=sample"<BR>

  3. #3
    Jb Guest

    Default THANKS :-)

    I will test it, but I already see the missing link.<BR><BR>("d", -21, myEndDate) <BR><BR>Ah, THAT I never knew about. I can&#039t wait to test it!<BR><BR>Thank you<BR><BR>

Posting Permissions

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