Hi!
I’ve been trying to create a system that stores absence of people attending a club
The club members can select the date when they are absent from and the date that they are absent too. This is stored in a database
The website has a function where you should be able to see who is absent within a selected range.
For example “I want to see who is absent between 01/08/2019 and 20/08/2019”
dFrom: The value entered into the first date picker
dTo: The value entered into the second date picker
^ this is to specify a range
dateAbsentFrom: the members first day on holiday
dateAbsentTo: the members last day on holiday
my code that don’t work while it does filter correctly, if say someone is on holiday between the start and end of 2019 and my selected date range is within this, then their absence is not shown
Thanks for the help
James
function filterAbsence()
{
$w(“#dataset2”).onReady( () => {
console.log(“The dataset is ready”);
let dFrom = $w(“#datePicker1”).value;
let dTo = $w(“#datePicker2”).value; // get today’s date
dFrom.setHours(0,0,0,0); // clear out the time
dTo.setHours(0,0,0,0); // clear out the time
$w(“#dataset2”).setFilter( (wixData.filter().ge(“dateAbsentFrom”, dFrom).and( wixData.filter().le(“dateAbsentFrom”,dTo))).or (wixData.filter().le(“dateAbsentTo”, dTo).and( wixData.filter().ge(“dateAbsentTo”,dFrom))))
.then( () => {
console.log(“Dataset is now filtered”);
} )
.catch( (err) => {
console.log(err);
} );
});
}