I have an event directory page that displays a list of events (i.e. repeater) including name, location and the date of the event. Since some events are multiple days long, I have an events database that collects both start date and end date for each event.
I am displaying a date picker for the user to select a “start date” and then another date picker for the user to select an “end date”. How can I return all entries where the event’s start date falls within the range specified by the date pickers?
import wixData from ‘wix-data’ ;
$w . onReady ( function () {
$w ( “#datesearch” ). onClick (() => {
let fromDate = $w ( “#startDatePicker” ). value ;
let toDate = $w ( “#endDatePicker” ). value ;
wixData . query ( 'Items1' )
. between ( 'date' , fromDate , toDate ) //'date' is the start date
. or ( wixData . query ( 'Items1' ). between ( 'endDate' , fromDate , toDate ))
. find ()
. then (( results ) => {
console . log ( results . items ); // display the selected items in the console
})
. **catch** (( err ) => {
console . log ( err );
});
});
});