I have some code that was written for me to filter between two dates, but it doesn’t work how I want it too. Basically the filter is for temporary holiday sites and some can be open for up to four weeks at a time but when using .ge and .le if someone searches for a 1 week period during the 4 week opening dates of the site then the site does not show up in the filtered data.
This is a snippet of the code used for filtering the dates.
function filter() {
let currentFilter = wixData.filter().not(wixData.filter().eq("status", "Withdrawn by DA"))
if ($w('#from').value) {
currentFilter = currentFilter.ge("startDate", $w('#from').value)
}
if ($w('#to').value) {
currentFilter = currentFilter.le("finishDate", $w('#to').value)
}
I am still struggling with this filter, I am in need of something that will filter during 2 dates rather than specifically equal to or greater than the first date and less than or equal to the end date.
This formula does not work if you want the search to pick up anything during those dates even if the start date is less than the search date.