Hi all,
I’m sure I’m missing something and it might be an easy fix sorry. I’m no expert, but working my way through with some code. I’ve successfully created some filters for a table that I have and it works great, but 2 of the filters are a Start and End Date.
When the page loads, the From Date defaults to today, and I have added some code to set the End Date to 12 month from today.
function loadTo ( ) {
let firstTime = $w ( ‘#SearchDateFrom’ ). value . getTime ();
let time12MonthHence = firstTime + ( 364 * 86400000 );
let date12MonthHence = new Date ( time12MonthHence );
$w ( ‘#SearchDateTo’ ). value = date12MonthHence ;
}
Again, this works great and populates the date with no issues. I then call another function to run the search, but it does not seem to pick up the populated date? I don’t get any search results, but if I then change the SearchDateTo, then it works great. It seems that the coded date is not being used int he criteria.
function SetTableFilter ( ) {
let CaravanID = $w ( “#CaravanIdentity” ). text
let variable = false
if ( $w ( ‘#SearchArchive’ ). value === ‘Yes’ ) {
variable = true
}
$w ( “#SearchDataset” ). setFilter ( wixData . filter ()
. contains ( “bookingStatus” , $w ( “#SearchBookingStatus” ). value )
. eq ( “archive” , variable )
. ge ( ‘startDate’ , $w ( ‘#SearchDateFrom’ ). value )
. le ( ‘startDate’ , $w ( ‘#SearchDateTo’ ). value )
. eq ( ‘caravan’ , CaravanID )
);
}
I know that I might not be using the most efficient code to get to what I need, but I’m learning as I go.
What am I missing? Any help would be really appreciated, thanks