Hello guys, I want to show real estate ad in a last month. The system already give me a date as Created date. I want to show in my repeater last 1 month.
Dairelersatilik is my database name.
Thanks for help!
import wixData from ‘wix-data’ ;
$w.onReady( function () {
const firstDate = new Date( 2021 , 3 , 1 , 1 , 1 ) // month is zero-indexed so need to subtract 1
const secondDate = new Date( 2021 , 3 , 10 , 1 , 1 ) // month is zero-indexed so need to subtract 1
wixData.query( "DairelerSatilik" )
.lt( "_createdDate" , firstDate) // Dates are stored in a field with field key "date"
.or(
wixData.query( "DairelerSatilik" )
.gt( "_createdDate" , 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);
});
});