Filter with dates is not working

No matter how i structure my code or what I try I am unable to filter my databases by date, it always just hides all the items in the database, I’ve listed a few of the things I’ve tried below.

// CODE THAT DOESN"T WORK AND I DON"T UNDERSTAND WHY

$w.onReady(function () {

  $w("#fridayShows").setFilter(wixData.filter().contains("date", '"Sun Apr 11 2021 00:00:00 GMT-0700 (Pacific Daylight Time)"'));
 // console.log($w("#fridayShows"));

});

// CODE THAT ALSO DOESN"T WORK AND I STILL NEED TO FIGURE OUT WHY

$w.onReady(function () {

  $w("#fridayShows").setFilter(wixData.filter().contains("date", 'Apr 9, 2021'));
 // console.log($w("#fridayShows"));

});

// Other Tries, just hides all events

$w.onReady(function () {

  $w("#fridayShows").setFilter(wixData.filter().eq("date", '2021-04-10T05:00:00.000Z'));
 // console.log($w("#dataset1"));

});

It seems that no matter how I format it the code still doesn’t like it.
I’ve console logged the date field itself and copied exactly what it produces and it STILL won’t work, really racking my brain here.

You are making 2 mistakes:

  1. a date is of type Date, not a string (which you are feeding it)
  2. JS dates consist of millisecs since Jan1, 1970. So they do not hold only a date, they hold a date + time. If you compare 2 dates, the chance that 2 dates (with the inseparable time part) will be the same is very, very small (a chance of 1-10006060*24). That is why, when working with dates, you filter using .between or >= AND <= with a lowerbound of the date set to 0:00:000 hours/secs/milsecs and an upperbound of 23:59:999 for the date you are looking for. That will find it.

BTW, this is not a Wix-related problem. It’s a JS problem : https://www.w3schools.com/js/js_dates.asp

And I agree, JS dates can be maddening.

Huh, I see, this is definitely something I wasn’t able to figure out, explains why nothing was working. I’m still a bit lost on how I would structure my code though. Do you have any examples of people filtering by dates with the bounds of the hours/secs/milsecs that I could take a look at?

Eventually I caved and started building my project with a text input instead and checking strings of (MM/DD/YYYY) instead because I was at my wits end.

Is it worth it to get familiar with sorting through dates using the date type or just by using strings that look like dates and dealing with it like that?

I really appreciate the help this is my first big project in a while and actually programming stuff from scratch

I am doing a very large project for hotel reservations, and I can tell you that if you use JS dates, your problems have not even begun. Just wait until you run into the problem that people in different time zones start feeding dates into your db, it will drive you half nuts.
I do not know if this will also be your problem, but using strings as a date is really not a bad idea, because they are constant, not relative (JS dates are calculated from GMT +0:00:000).
The only thing you must do is NOT store them as MM/DD/YYYY but as YYYYMMDD. That way they sort properly.

Fortunately I am focused mainly on southern California now so the time zone’s will remain consistent however, with the goal of expanding in the future I will need to worry about time zones. I am very thankful for the expert help. I will take note of storing them as Year Month Date though because that will become a serious issue for sure. I should be good to go! Thank you!