This is a migrated thread and some comments may be shown as answers.

Grid datetime filter not working

1 Answer 217 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maurizio
Top achievements
Rank 1
Maurizio asked on 23 Jan 2020, 04:11 PM

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
    }
  ]
}

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 24 Jan 2020, 09:23 AM

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
Tags
General Discussions
Asked by
Maurizio
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or