Filter not working for DateTime columns with "equal To" filter

9 posts, 0 answers
  1. Matt
    Matt avatar
    23 posts
    Member since:
    Mar 2011

    Posted 22 Nov 2011 Link to this post

    I can't get the filters for 'equal to' working on date time column in rad grid. As far as I can tell this has something to do with the times on the dates. I have seen many posts about this here with no answer so I guess I don't really expect help, but just throwing my voice in with everyone else saying your filters don't work right for date time columns. Period.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Nov 2011 Link to this post

    Hello,

    I have tried the same and worked as expected. You can take a look into the following demo.
    Grid / Basic Filtering

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Preeti
    Preeti avatar
    7 posts
    Member since:
    Jul 2013

    Posted 26 Jul 2013 Link to this post

    I tried the code shown in the demo but the filter does not work for me.
    The date time column in database is saved as '2013-07-26 00:01:09.840' format. whereas in the grid the value is displayed as '7/26/2013 12:01:09 AM'. This should not be a problem as far as I think.
    I am giving the value '7/26/2013 12:01:09 AM' in the text box to search with Filter option as 'Equal To'. No results are returned when I have selected this value from the grid itself.

    Greater than and Less Than filter options work fine. Just the equal to is not.

    Please tell me what is wrong here.
    Thanks
  5. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 31 Jul 2013 Link to this post

    Hi Preeti,

    This behavior is expected since the "2013-07-26 00:01:09.840" is not equal to "2013-07-26 00:01" which is the value used for filtering. The picker assumes the entered date to have starting seconds and milliseconds: "2013-07-26 00:01:00.000", which makes it different than the desired: "2013-07-26 00:01:09.840".

    To resolve this issue, you can either enable the following property:
    <telerik:GridDateTimeColumn ... EnableTimeIndependentFiltering="true">
    Or prevent the filter command when the selected function is EqualTo and use Contains function instead.

    Hope the clarification was helpful.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Preeti
    Preeti avatar
    7 posts
    Member since:
    Jul 2013

    Posted 06 Aug 2013 Link to this post

    Hi Eyup,
    Thanks a lot for the reply.
    I need to understand what value comparison is going on by the telerik filter/grid.

    Because the grid column shows the value  '7/26/2013 12:01:09 AM' and this is what I am entering in the filter textbox. so ideally it should fetch the data correctly.

    Also I don't have the option of EnableTimeIndependentFiltering.I think the version of control I am using is different. am I right?

    Please let me know a way to make this work.'

    Thanks,
    Preeti
  7. Kunal Chowdhury
    Kunal Chowdhury avatar
    23 posts
    Member since:
    May 2010

    Posted 06 Aug 2013 Link to this post

    Hi Preeti,

    Eyup is right. The value that you have in database is '2013-07-26 00:01:09.840' and when you bind it to DataGrid and display in the UI, it shows like this: '2013-07-26 00:01:09' where 840 milliseconds different is there. Now, when you are doing a comparison with EqualTo() operator, you are just neglecting that delta value 840. Thus the comparison returns false.

    In case you want to implement that functionality, you have to override the EqualTo() operator or write some additional logic to compare both the sides without that delta difference.

    Hope this clarifies your query. Let us know, if you still have any queries on this.

    Regards,
    Kunal Chowdhury
    www.kunal-chowdhury.com

    (Mark as answer, if this helped you)
  8. Preeti
    Preeti avatar
    7 posts
    Member since:
    Jul 2013

    Posted 06 Aug 2013 Link to this post

    Thank you Kunal. Let me try out what you and Eyup have suggested and I will come back if I have any questions.

    Thanks Again,
    Preeti
  9. Vishal Nahar
    Vishal Nahar avatar
    1 posts
    Member since:
    Sep 2009

    Posted 16 Sep in reply to Kunal Chowdhury Link to this post

    I have formatted the Editor text box the date time picker etc to have the milliseconds but still it is not filtering, as the filter descriptor does not have milliseconds 
  10. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 21 Sep Link to this post

    Hello Vishal,

    Have you tried setting the following property?
    <telerik:GridDateTimeColumn ... EnableTimeIndependentFiltering="true">

    Regards,
    Eyup
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017