Hey all,

Came across this site while scouring the web for a solution to my problem. All of the answers on here seem very helpful and non judgmental. That is hard to come by in a lot of programming forums, so thanks.

My Question.

I am using VS 2008 and have a DataGridView linked to a SQL table. One of the columns in my table is a dueDate column. On my form I have a set of check boxes and one of them is set to display all rows that have a dueDate > today's date (well that's what I want it to do). I have set up another filter on other criteria in other columns and am able to get it to work fine but I can't seem to find the trick to get the date comparison to work.

Here's the line I am having an issue with.

BillLogBindingSource.Filter = ("dueDate < System.DateTime.Now.Date")

Thanks in advance for any advice.

Recommended Answers

All 6 Replies

filter at the backend server only?

filter at the backend server only?

I'm not sure why I would want to do this. Please explain if you have a reason that this would be better. I figured I would just filter the data in the dataset(since it's just for viewing purposes only) instead of just filtering the table and forcing the dataset to update.

In dataview you can filter and show the result in grid, In database also you can filter and get the desired result set. choose what you want to do.
What is the problem you are facing when ur filtering in dataview? Can you post the bit more code? and problem details?

Here is some code that I have that works.

Private Sub chkBxStatusPaidProcessing_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkBxStatusPaidProcessing.CheckedChanged
        'Filters datagridview based on the conditions of paidProcessing
        If (chkBxStatusPaidProcessing.CheckState = 1) And (chkBxStatusAll.CheckState = 0) Then
            BillLogBindingSource.Filter = ("datePaid IS NOT NULL And confirmation IS NULL")
        ElseIf (chkBxStatusPaidProcessing.CheckState = 0) Then
            BillLogBindingSource.Filter = Nothing
        End If

    End Sub

I would like to do the same thing as above, just filter the date column. I would like to show only rows where the dueDate > today. Thanks again for the help.

Still looking for some help on this if anyone out there has any ideas. I am sure this easy I just can't figure it out. Thanks

Member Avatar for Unhnd_Exception

Hey Try This

.Filter = "dueDate < #" & System.DateTime.Now & "#")

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.