Date(timestamp) filter is not working in adodb recordset RRS feed

  • Question

  • I am reading data from DB and dumping it to data Grid in C#. Here whenever I apply filter on recordset for system date type. it is not filtering and returns row count as 0.

    In data grid UI, I have text box to type date for filter. The data in grid looks like

     1/7/1989 1:45:25 PM 
     8/7/2000 10:5:20 PM
     6/1/1980 5:16:12 AM

    and user is typing "1/7/1" to filter all record with matching date. The query to filer is

    string filter = "[DateTime] = #1/7/1#";
    Recordset.Filter = filter;
    int count = Recordset.RecordCount;

    Here the count is always 0. But if i do like

    string filter = "[DateTime] = #1/7/1989 1:45:25 PM#";
    Recordset.Filter = filter;
    int count = Recordset.RecordCount;

    Then it is able to filter. As user cannot type entire date with time. So want a solution to filter based on partial date input.


    Friday, April 26, 2019 4:25 AM

All replies

  • If the Filter does not accept a function that strips the time part, then maybe build filters like this:


       string filter = "[DateTime] >= #1/7/1989 00:00:00#  AND  [DateTime] <= #1/7/1989 23:59:59#";


    Friday, April 26, 2019 5:34 AM
  • As user can type the filter string so at one point if user types "1/7/" then i need to show all the entry which has time like 1/7/***


    Friday, April 26, 2019 5:50 AM
  • Hi Nihal_dev,

    Since your question is more related to SQL, you could post a new thread in SQL.


    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, May 2, 2019 6:21 AM