Can some intelligent being explain why

this code below doesn’t produce the intended result? I have 2 dates in my dataset, a startDate and an endDate. The code wants to create a filter based on the startDate being before “today” and the endDate being after “today”. The following code generates this result:
Error: Failed to build a filter. Invalid .ge field value [Date]. .ge field must be a String. Invalid .lt field value [Date]. .lt field must be a String…

my code follows:

import wixData from ‘wix-data’;

$w.onReady( function () {
$w(“#promoDS”).onReady( () => {
console.log(“The dataset is ready”);
let d = new Date();
d.setHours(0,0,0,0);

    $w("#promoDS").setFilter( wixData.filter() 
    .between(d,"startDate", "endDate")  
    ) 
    .then( () => { 
        console.log("Dataset is now filtered"); 
    } ) 
    . **catch** ( (err) => { 
      console.log(err); 
    } ); 
}); 

});

I have tried converting these date objects in several ways but without success. Also, I tried solving this problem earlier in the year using lt. and or. with the help of wix developers, but this never worked correctly. This is a frustrating problem, that would have been easy to solve had there been a simple .and operator. Why there isn’t is beyond my understanding.

Hi,
Between method is expecting a String || Number || Object.
In your code it’s “startDate”, “endDate” which means nothing.
Check out this example:

import wixData from 'wix-data';

// ...

wixData.query("myCollection")
  .between("age", 25, 65)
  .find()
  .then( (results) => {
    let items = results.items;
    let firstItem = items[0];
    let totalCount = results.totalCount;
    let pageSize = results.pageSize;
    let currentPage = results.currentPage;
    let totalPages = results.totalPages;
    let hasNext = results.hasNext();
    let hasPrev = results.hasPrev();
    let length = results.length;
    let query = results.query;
  } )
  .catch( (error) => {
    let errorMsg = error.message;
    let code = error.code;
  } );

For more information:

Roi.