PDA

Click to See Complete Forum and Search --> : SQL to search a database for results between 2 dates


roars
Sep 1st, 2000, 05:17 AM
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?

Joegei
Sep 1st, 2000, 05:37 AM
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

AdrianH
Sep 1st, 2000, 07:01 AM
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