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?
Printable View
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?
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
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