Results 1 to 3 of 3

Thread: SQL to search a database for results between 2 dates

  1. #1

    Thread Starter
    Junior Member roars's Avatar
    Join Date
    Jun 2000
    Location
    Northern Ireland
    Posts
    19
    I am trying to write an sql that will take 2 dates from a drop down date picker box and perform an sql on a database to bring back the data logged between the dates. Can anyone help?

  2. #2
    New Member
    Join Date
    Sep 2000
    Posts
    4
    Without going into parameter collections and such, you could try creating a text string that contains the SQL command.

    The string would look something line this

    strSelect = "Select * From table1 " _
    & "where Date Between " & txtStartDate.text _
    & " And " & txtEndDate.text

    Then when you open your recordset, use strSelect as the source string.

    Hope this helps


  3. #3
    Lively Member
    Join Date
    Aug 2000
    Location
    Australia
    Posts
    82
    You could also try the DateValue function, I found this worked for me when specifying dates.

    For example

    SQLStatement = "SELECT [Records] From [Table] WHERE [ThisField] between DateValue('" & StartDate & "') and DateValue('" & EndDate & "')"

    Cheers
    Adrian

Posting Permissions

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



Click Here to Expand Forum to Full Width