We are using the DateFilter from kendo-react-data-tools to filter Odata Edm.Date fields. Neither the DateFilter nor the Edm.Date fields have a time component, but toODataString from kendo-data-query turns the DateFilter value into a DateTimeOffset e.g. YYYY-MM-DDT00:00:00.000Z.
Is it possible to get a date-only value from toODataString using DateFilter?
Hi, David,
Thanks a lot for the submitted feature request - we will monitor the interest in it closely!
Currently, there is no built-in configuration in toODataString to output date-only strings for Edm.Date fields. The toODataString method from @progress/kendo-data-query always serializes JavaScript Date objects as full date-time strings (e.g., "YYYY-MM-DDT00:00:00.000Z"), even when the target field in OData is of type Edm.Date, which expects a date-only value ("YYYY-MM-DD").
To generate a date-only value, you can try to manually format your filter value before passing it to toODataString in a similar way:
const dateToEdmDate = (date) => date.toISOString().slice(0, 10);
const filter = {
logic: 'and',
filters: [
{
field: 'FirstOrderedOn',
operator: 'eq',
value: dateToEdmDate(selectedDate), // selectedDate is a JS Date object
},
],
};
const odataString = toODataString(filter);
Kind Regards,
Vessy
Progress Telerik
Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.