Date Parameters

Results 1 to 3 of 3

Thread: Date Parameters

  1. #1
    Jerry S. Guest

    Default Date Parameters

    I am using a form and DSN connection to query data out of an access database. I would like to add a beggining and an ending date form field to query the extracted data by a date range. Does anyone know how to set parameters with ASP to query information out of an Access 97 Database based on a date range?

  2. #2
    Chris Willey Guest

    Default RE: Date Parameters

    Sure.<BR><BR>First set up the form where people enter start and end dates. If you can do this with drop-down lists instead of freeform text boxes, do it (i.e.: a separate drop down for month, day and year) otherwise you&#039ll have to deal with people being stupid about data entry.<BR><BR>Then, in your search page, do this:<BR><BR>&#060;%<BR>Dim objConn, objRS<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open "DSN"<BR>Set objRS = Server.CreateObject("ADODB.RecordSet")<BR>objRS.Op en "SELECT * FROM table WHERE start_date >= &#039 & Request("startdate") & "&#039 AND end_date &#060;= &#039 & Request("enddate") & "&#039", objConn, adOpenStatic, adLockOptimistic<BR>&#037;&#062;<BR><BR>I don&#039t remember if the single quotes around the search terms are needed when doing date queries, so if the above doesn&#039t work try removing them.

  3. #3
    Jeremy S. Guest

    Default RE: Date Parameters

    I haven&#039t done this in a while, but with Access you might need to put "#" signs around your date.<BR><BR>Sort of like this when building your SQL string...<BR><BR>&#039...WHERE TheDate >=#&#039 & Request("TheDate") & &#039#&#039 <BR><BR>Hope this helps...<BR><BR>--Jeremy S.<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
  •