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)
@MartynLiv which type of data source are you using? Not all connectors support data comparison directly, and depending on which one you have you may need to use a different expression.
Continue your learning in our online communities.
Next Wednesday, August 21st at 8am PDT
Let's thank our top community contributors
Features releasing from October 2019 through March 2020
Coming to a city near you
Fill out a quick form to claim your user group badge now!
Connect, share, and learn with your peers year-round
Features releasing from April 2019 through September 2019!
August 20-23rd 2019