You can use WixDataQuery filters to filter content that you query from your database collection. Then display only the filtered content.
For example, the following code snippet uses the gt() (greater than) and lt() (less than) filter functions to check for database collection items before 05/03/2020 or after 15/12/2015 :
import wixData from 'wix-data';
$w.onReady(function () {
const firstDate = new Date(2020, 2, 5) // month is zero-indexed so need to subtract 1
const secondDate = new Date(2020, 11, 15) // month is zero-indexed so need to subtract 1
wixData.query("MyCollection")
.lt("date", firstDate) // Dates are stored in a field with field key "date"
.or(
wixData.query("MyCollection")
.gt("date", secondDate)
)
.find()
.then((results) => {
if (results.items.length > 0) {
let items = results.items; // Filtered items to display
} else {
// handle case where no matching items found
}
})
.catch((error) => {
console.log(error);
});
});