Loading table with code at page opening

Hi,
As I can’t filter in the dataset parameters on a date-time field, I need to populate the table at page opening with code.
But where should I put this code ? I tried in the “page1” property “onViewportEnter”, but it does not work. Or is it possible to put only some filtering with code somewhere, as apparently anyway the dataset is loaded with the page if I want the columns linked with the collection…
This is the code I could use for that:

$w('#dataset1').onReady(() => {
 let dpd = $w('#dropdown1').value;
 var lowerYear = dpd.substring(0,4);
 var upperYear = dpd.substring(5,9);
 var lowerDate = new Date(lowerYear.concat('-','9','-','1'));
 var upperDate = new Date(upperYear.concat('-','6','-','30'));
 
        wixData.query('match')
        .gt('dateHeure', lowerDate)
        .lt('dateHeure', upperDate)
        .descending('dateHeure')
        .limit(300)
        .find()
        .then( (res) => {
 let tableRows = res.items;
           $w('#table1').rows = tableRows;
        })
    })
}

https://www.wix.com/corvid/forum/community-discussion/filtering-a-dataset-in-wix-code

Thank you givemeawhisky, but this post doesn’t explain where to put the code ! if it is in the
$w(“#dataset”).onReady() event, it won’t work for me, as this event is fired every time the user changes the dataset with dropdown user selected values. What I need is a fixed code filter selection for the page opening only, populating my table for the first time only.