Advanced DataGridView DateTime Filter

2.2k Views Asked by At

In my win form application I have used 'Advanced DataGridView'. For filter string columns it is working good but when i filter Datetime column the grid view becomes empty. When i did debug it, i came to known that it is getting only dates and not dateTime from the column i.e

([Date_Time] IN ('11/04/2017', '12/04/2017', '13/04/2017'))

and this is the reason why my grid view become empty because there is no row with only date.

here is my code for 'Change filterString' event

Me.crossMatchBindingSource.Filter = dgvCrossMatchDetails.FilterString

So, my question is how can i include time in the filter.

3

There are 3 best solutions below

0
Muhammad Haroon On BEST ANSWER

Please correct me if i m wrong. whoever created AdvancedDataGrid, the code he/she wrote to filter can only filter the date and not the datetime. So i should split my datetime in two columns then i will be able to filter my dates. Actually i have done it and it is working perfectly but time column shows every record separately like text in the filter and not making grope of hours and minutes as excel does.

3
w0051977 On

I believe you are trying to bind a grid view to a data source, which uses SQL to extract data from the databases. I believe you can just amend your SQL as follows:

([Date_Time] between ('11/04/2017' and '14/04/2017'))

This should cater for times as well as dates.

0
Josh On

You should just go to DataGridView properties and set "DateWithTime" to "True". Then you are able to filter by Date and Time now.