Hello everyone,
How do I create a button that filters a dataset to show only items from the last month.
Thank you.
Hello everyone,
How do I create a button that filters a dataset to show only items from the last month.
Thank you.
Eny help please
You can do something like this:
import wixData from 'wix-data';
$w("#myButton").onClick( (event) => {
let first = < first day of last month >;
let last = < last day of last month >;
$w("#myDataset").setFilter( wixData.filter()
.ge("date-field", first)
.le("date-field", last)
)
.then( () => {
console.log("Dataset is now filtered");
} )
.catch( (err) => {
console.log(err);
} );
} );
This should get you going in the right direction.
will it work with the week and the year in the same way?
@oussamaismaili7 You just need to set first and last variables to the correct dates.
Thank you so much @yisrael-wix
@yisrael-wix
Do you know a way to get last year’s date based on today’s current date.
let yearValue = (localDate.getFullYear() - 1 ) ;
@oussamaismaili7 I did a search for javascript get date year ago and I got lots of results. One good one is: How to determine one year from now in Javascript
Good luck.