0

i need to filter my table between 2 dates

but it makes wrong filtering really i dont understand why. but it might be my wrong codes

here is my codes... what should i do?

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   Dim da As New SqlDataAdapter("SELECT * FROM TableName WHERE DateColumn BETWEEN '" & _
   DateTimePicker1.Value & "' AND '" & DateTimePicker2.Value & "'", Connection) 
   Dim dt As New DataTable
   da.Fill(dt)
   Dim dv As New DataView(dt)
   DataGridView1.DataSource = dv
End Sub

Thanks for your helping :)

2
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Oneryavuz
2

What do you mean by wrong filtering? It's returning something it shouldn't or not returning something that it should?

Anyway, I would try DateTimePicker.Value.ToString("yyyy-MM-dd")

0

It's returning something it shouldn't.

Also its works ===> DateTimePicker.Value.ToString("yyyy-MM-dd")

ahh right now i understand....

Thank you very much :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.