Grid datetime filter not working

2 posts, 0 answers
  1. Maurizio
    Maurizio avatar
    5 posts
    Member since:
    May 2016

    Posted 23 Jan 2020 Link to this post

    Hi,

    I'm using kendo grid to display data that come from OData service (build in asp net core).

    Date filter is not working for datetime columns.

    The issue is related to time value that is passed as filter (an example down below).

    Is there a way to avoid time in filter?

    Thanks

    Maurizio

     

    NO RESULTS

    /api/P6activity?$count=true&$filter=(finishDate eq 2020-01-23T00:00:00.000Z and projectId eq 'H171P')

    CORRECT RESULTS

    /api/P6activity?$count=true&$filter=(finishDate eq 2020-01-23 and projectId eq 'H171P')

     

    {
      "@odata.context": "http://localhost:11111/api/$metadata#P6activity",
      "@odata.count": 3,
      "value": [
        {
          "id": 566,
          "projectId": "H171P",
          "activityId": "M194",
          "name": "Demi Mechanical Document",
          "startDate": "2019-11-15T13:00:00+01:00",
          "finishDate": "2020-01-23T17:00:00+01:00",
          "sapControlKey": null,
          "sapTransfer": false,
          "sapMaterialGroup": null,
          "sapPurchGroup": null,
          "sapOdA": null
        },
        {
          "id": 739,
          "projectId": "H171P",
          "activityId": "Q176",
          "name": "MEP Works Order",
          "startDate": "2019-12-23T08:00:00+01:00",
          "finishDate": "2020-01-23T17:00:00+01:00",
          "sapControlKey": null,
          "sapTransfer": false,
          "sapMaterialGroup": "Z003",
          "sapPurchGroup": null,
          "sapOdA": "0260"
        },
        {
          "id": 970,
          "projectId": "H171P",
          "activityId": "U080",
          "name": "Thermal Cycle Sampling System Mechanical Drawings",
          "startDate": "2019-12-16T08:00:00+01:00",
          "finishDate": "2020-01-23T17:00:00+01:00",
          "sapControlKey": null,
          "sapTransfer": false,
          "sapMaterialGroup": null,
          "sapPurchGroup": null,
          "sapOdA": null
        }
      ]
    }
  2. Stefan
    Admin
    Stefan avatar
    3008 posts

    Posted 24 Jan 2020 Link to this post

    Hello, Maurizio,

    In this case, we can suggest to programmatically strip to time part of the date filter string. Based on the provided values splitting them by "T" will be the fastest way. Then pass to the server only the date part of the filter

    As the time part is an official part of the JavaScript Date object and we have no control over that to remove it automatically.

    Let me know if you need additional information on this matter.

    Regards,
    Stefan
    Progress Telerik

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top