Filter Events calendar by DateTime

I’ve got a simple events calendar which has DateTimes in it for the events. I want to filter that automatically; at the moment I’ve created a boolean column in the DB that I’m manually marking when an event is in the past, and the dataset is filtered on this column.

I’d like to automate the process, and would be able to do it in Python, but don’t know where to get this working - any help/pointers would be appreciated as doing it manually is a PITA.

let today = new Date();
today = today.toLocaleDateString();
// You will need to format your date in the today variable to match the date format in your Data Collection of course

Then you just use setFilter in WixData to use the greater than gt and take in your today as the filters value and the dataset will automatically be filtered to show just future events.

HI Andreas. Thanks for your reply - however, I can’t make head or tail of where to do this - how it’s implemented, if it’s a hook in the database get or whatever… it’s light years ahead in a language I don’t speak, on a platform that seems much too complex to implement something like this. Thanks again, but it’s beyond me to implement your help.

Ok, send in here screenshots of your data collection structure and your page also and I will look into making the code for you.

Hi Andreas. Thanks - any help you can give will be hugely appreciated.

I’ve attached a shot of the data structure - past_gig is the boolean that I created to make it easy to mark a gig as in the past (and therefore not displayed), and the site is currently filtering the data using that (successfully) - it’s the automation of marking this column (I would assume on page views as I’ve not seen anything similar to running a cron job) which I can’t work out - I spent about an hour reading the help yesterday to little avail. I got as far as thinking that a hook on ‘Before Get’ would be needed, but I couldn’t make much of the documentation, or how to iterate through the data while doing this.

As you can see, this is some of the table, but there are other entries, and those past ones are marked with the tick in past_gig and don’t display (there are others further down that don’t currently have a tick).

Many thanks