Mr.Wobbles 0 Light Poster

I need to filter the results from a database by year, and so far I have tried several different things, I will list a couple of examples below, I would like to use this one:

ServiceAndTeamContributionsBindingSource.Filter = String.Format("WHERE datePart('YYYY',BeginYear) <= '" & endDateBox.Text & "' AND datePart('YYYY',BeginYear) >= '" & begDateBox.Text & "'")

But I have also tried something like this:

Dim STCdateOne As String = begDate
Dim STCdateTwo As String = endDate
Try
Me.ServiceAndTeamContributionsTableAdapter.STC_Date_Restrict(Me.PortfolioDBDataSet.serviceAndTeamContributions, STCdateTwo, STCdateOne)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

The .STC_Date_Restrict is a sql command in the database data set. It looks like this:

SELECT *
FROM serviceAndTeamContributions
WHERE datePart('YYYY',BeginYear) >= ?
AND datePart('YYYY', BeginYear) <= ?

Whichever one you guys think will work easier, tell me how to fix that one. Currently they both just filter out all of the records instead of the ones between the dates. Any help is appreciated, thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.