Using Date Parameters in SQL statement

Results 1 to 2 of 2

Thread: Using Date Parameters in SQL statement

  1. #1
    Join Date
    Dec 1969

    Default Using Date Parameters in SQL statement

    I want to input a &#039from&#039 and a &#039to&#039 date in a form on a previous page, submit it, and then use those dates in a SQL statement using BETWEEN to only show records that were created between those dates.<BR><BR>I have the form submitting the data ok, I am working with FrontPage2000 which doesnt seem to allow you to validate the format of the text box to a date field. Ignoring the preceeding form I have added some temporary variables:<BR><BR>Start_Date = "12/15/99"<BR>End_Date = "1/15/00"<BR><BR>When I try to use them in the SQL I get a data missmatch error, I have tried using the US dating format i.e. 1/15/99 and the UK 15/1/99 but to no avail. <BR><BR>So basically this amounts to 2 questions, <BR>1)How do I validate the data input into the form on the preceeding page?<BR>2)How do I then use the dates in an SQL statement?<BR><BR>Any advise would be gratefully received<BR><BR>Thanks

  2. #2 Guest

    Default RE: Using Date Parameters in SQL statement

    1) FrontPage does not do format validation - you need to use a java script to validate the form when they click submit.<BR><BR>2) I do not know what DB you are using, but I am going to guess MS Access. You need to format your dates using a # sign in Access.. Like this:<BR><BR>lSql = "Select * from my_table a where [a].[date] between #" & request.form("start_date") & "# AND #" & request.form("end_date") & "#"<BR><BR>Remeber that this is an inclusive filter.<BR><BR>Hope this helps.<BR><BR>-Bill Case<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