Hi Corvid Community!
I wondered if anyone could help with my coding problem which I imagine will appear rather trivial.
I have a dataset incorporating a bunch of sayings/quotes that have specific dates (‘month’ and ‘day of month’) attached to them. There is x1 ‘month number’ column (Field Key: monthNumber) and x1 ‘day of month’ column (Field Key: day) - both of field type: number. Each row therefore comprises a quote, month number and day of month number.
I want to display a repeater that shows the following:
- the quote in dataset1 based on the date today (whichever day of the year ‘today’ happens to be)
- the quotes in dataset1 for the subsequent 30 days after today’s date including when this extends
into the following month.
Code so far:
import wixData from ‘wix-data’ ;
import wixWindow from ‘wix-window’ ;
let getDate = true ;
$w.onReady( async function () {
const today = new Date();
const day = today.getDate();
const month = today.getMonth();
$w( “#dataset1” ).onReady( async () => {
$w( “#dataset1” ).setFilter(wixData.filter()
.eq( “day” ,day) //“day” = field ID of month day in dataset1 with numeric property
.eq( “monthNumber” , month) //“monthNumber” = field ID of month number (Jan = 0) in dataset1 with numeric property
)
.then(() => {
let file = $w( “#dataset1” ).getCurrentItem();
})
. catch ((err) => {
console.log(err);
});
});
});
This code succeeds in filtering the database by today’s date however I can’t work out how to pull quotes for ‘today +1’, ‘today+2’ etc?
I tried the following:
$w( " #dataset1 " ).onReady( async () => {
$w( " #dataset1 " ).setFilter(wixData.filter()
.eq( “day” ,day)
.eq(“day”, day+2)
.eq(“day”, day+3)
BUT it didin’t work
I then tried:
$w( " #dataset1 " ).onReady( async () => {
$w( " #dataset1 " ).setFilter(wixData.filter()
.eq( “day” ,day+2)
and this did pull the quotes from the date 2 days in the future BUT again I can’t display results for anything more than 1 single day.
I would be grateful if anyone might know a way to get the quotes for today AND the subsequent 30 days such that they all appear on the page simultaneously?
Many thanks in advance for any help offered.
Mark