I'm trying to display in a DataTable that takes records from CDS all the rows that have the date field between two dates (chosen by DatePickerStart and DataPickerEnd selection).
What I can do now is a Filter in which I can select records of one specific date:
Filter(checkin; StartsWith(cr5a8_dataoraregistrazione; Text(DatePicker.SelectedDate)));
But how can I extend it in a range of two dates?
Thanks for your help!
You can use the < and > comparison operators (or <= and >=) to check if a field is between two dates, like in the example below. That will work if the field cr5a8_dataoraregistrazione is of type "Date Only" ("Solo data") or "Date and Time" ("Data e ora") in your CDS entity.
Filter( checkin; cr5a8_dataoraregistrazione >= DatePicker1.SelectedDate; cr5a8_dataoraregistrazione <= DatePicker2.SelectedDate)
I tried this and got the following error :
The requested operation is invalid. Server Response: We cannot apply operator < to types DateTime and DateTimeZone. Inner exception: We cannot apply operator < to types DateTime and DateTimeZone.
You should use DateDiff function for comparing dates
Filter( checkin; DateDiff(cr5a8_dataoraregistrazione,DatePicker1.SelectedDate) >= 0 && DateDiff(cr5a8_dataoraregistrazione , DatePicker2.SelectedDate) <= 0)