We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,376 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

SQL Select Between Two Dates

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
3 Hours
Discussion Span
9 Months Ago
Last Updated
3
Views
Question
Answered
Oneryavuz
Junior Poster in Training
70 posts since Jul 2011
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0

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")

AleMonteiro
Master Poster
752 posts since Aug 2010
Reputation Points: 129
Solved Threads: 140
Skill Endorsements: 23

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 :)

Oneryavuz
Junior Poster in Training
70 posts since Jul 2011
Reputation Points: 10
Solved Threads: 3
Skill Endorsements: 0
Question Answered as of 9 Months Ago by AleMonteiro

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0588 seconds using 2.68MB