I need help in selecting between date ranges. I have two dateTimepicker and want to retrieve only records selected between selected dateTimepicker.I tried but im getting all records. I'm using SQL server database. Here is my code:
selectQuery = "SELECT * FROM EmployeeRegistration WHERE EmpJoinDate BETWEEN '" & DateTimeFrom.Value.Date & "' And '" & DateTimeTo.Value.Date & "' ORDER BY EmpJoinDate"
cmd = New SqlCommand(selectQuery, conn)
DataGridView2.DataSource = DataSetViewEmp.Tables("EmployeeRegistration").DefaultView