Reputation: 197
I have an DataGridView with about 13000 records and I want to filter it by date. Problem is I don't know how! Currently if I want to filter the DGV according to string I use the following code
If TextBox1.TextLength > 0 Then
frmReportMenu.ProjectBindingSource.Filter =_
String.Format("[User no] Like '*" & TextBox1.Text) & "*'"
Else
frmReportMenu.ProjectBindingSource.Filter = String.Empty
End If
But I have no idea what to use for date, since date is not the same as String.Format
Can someone please help?
Upvotes: 0
Views: 4228
Reputation: 5423
If you want to filter by two DateTimePicker dates, do this :
Dim DateFrom as string = String.Format("[YourDateField] >= '{0:yyyy-MM-dd}' ", DateTimePickerFrom.Value)
Dim DateTo as string = String.Format("[YourDateField] <= '{0:yyyy-MM-dd}' ", DateTimePickerTo.Value)
frmReportMenu.ProjectBindingSource.Filter = String.Format("{0} AND {1}", DateFrom, DateTo)
Upvotes: 1