I have a collection I made to display event dates and information. Right now it displays all records. How would I display records matching the current date and event dates in the future? Although I can filter directly in the collection, the filter doesn’t apply when I display the records on the webpage. Thanks, Mark
Press the Filter-icon in the upper right corner for filtering in Content Manager. For datasets, you can do it inside the editor.
Thanks for your reply. Unfortunately the dataset in the editor doesn’t offer a way to select After or Current Date as a filter option like it does in Content Manager. Only conditions are Is empty or Is not empty. Setting it in Content manager doesn’t apply it in the dataset. I think I need something in Velo.
Ok, I get you. Yes, you will have to put in a few lines of code. See https://www.wix.com/velo/reference/wix-dataset/dataset/setfilter
Thanks. I’ll try to figure it out.
Hi, @ocphotog . I had a similar situation and posted about it. I think you’ll find detailed information on that thread that may help you:
Thanks for the link. I’ll take a look.
Hi Jim, Thank you so much for the information. Once I got my head around it I realized that this worked perfectly using just the .ge function to filter dates equal or greater that todays date
Hi @ocphotog i was having trouble with this aswell, but a friend helped me with the following code:
import wixData from ‘wix-data’;
$w.onReady(function () {
$w(“#MyCollection”).onReady(() => {
let sToday = new Date().toISOString().split(‘T’)[0];
$w(“#MyCollection”).setFilter(wixData.filter().ge(“DATEfieldkey”, sToday));
});
});
Just replace, MyCollection & DATEfieldkey
Hi Dylan, thanks for taking the time to respond. I was able to solve the problem and everything is working well. Thanks
Hi @ocphotog I am currently going through a similar challenge please help. I would like to filter content on a collection such that it only displays information with Current date only on a table on the website, how can i archive that ?
Hello! If you have a question please start a new post with the code you have attempted and where you are stuck. I am closing this post as it is over a year old, but you may reference/link it in a new question if it helps with context.