dates are not retrieved properly from query

Hi,
I want to bring all rows from a collection that their date is before 2 weeks ago

let lastDays = new Date();
lastDays.setDate(lastDays.getDate() -14);
wixData.query(“collectionName”)
.limit(1000)
.le(“dateField”,lastDays)
.or(wixData.query(“collectionName”) .isEmpty(“dateField”) )
.find()

It brings me rows that their date is few days ago…
what am I missing?

wix? is this a bug or am I doing anything wrong?

Maybe the dates in your collection are not set correctly (or the field type) (?) Can it be the problem?

Hmm… nothing seems to be wrong with that code. I created a collection with that name and with that date field and then entered various records with dates before and after the two week mark. Only the ones in the last two weeks were returned.

The field type is set correctly (date and time) and the dates are set properly in the collection. But I noticed they are set as MM/DD/YYYY - perhaps it query as DD/MM/YYYY and this could explain why only few dates are not retrieved properly and not all of them?

It doesn’t matter how they’re presented, they’re really saved as the number of milliseconds that have passed since 1/1/1970 00:00:000

So .le() functions like .ge() ?
Sounds like a bug…

so what could be the problem?

No idea. Your code looks fine. Maybe ask the Wix moderators after the weekend.

The “bug” was in what I wrote. What I meant to say in the last sentence was that only those prior to two weeks ago were returned. In other words, I am getting the results that Anatarad was expecting and doesn’t get.

@tony-brunsman I see.
So @anatarad , it worked for Anthony, so the code is fine, and the problem is somewhere else. I don’t think we can help with that.