this code below doesn’t produce the intended result? I have 2 dates in my dataset, a startDate and an endDate. The code wants to create a filter based on the startDate being before “today” and the endDate being after “today”. The following code generates this result:
Error: Failed to build a filter. Invalid .ge field value [Date]. .ge field must be a String. Invalid .lt field value [Date]. .lt field must be a String…
my code follows:
import wixData from ‘wix-data’;
$w.onReady( function () {
$w(“#promoDS”).onReady( () => {
console.log(“The dataset is ready”);
let d = new Date();
d.setHours(0,0,0,0);
$w("#promoDS").setFilter( wixData.filter()
.between(d,"startDate", "endDate")
)
.then( () => {
console.log("Dataset is now filtered");
} )
. **catch** ( (err) => {
console.log(err);
} );
});
});
I have tried converting these date objects in several ways but without success. Also, I tried solving this problem earlier in the year using lt. and or. with the help of wix developers, but this never worked correctly. This is a frustrating problem, that would have been easy to solve had there been a simple .and operator. Why there isn’t is beyond my understanding.