Question:
How to insert where clause for dates using wix sql library
Product:
Wix Editor.
What are you trying to achieve:
I’m trying to perform a query using SQL, which returns data with a specific time period. As if it were
.ge(“data”, startDate)
.le(“data”, lastDate)
What have you already tried:
Using the library: ‘@velo/wix-data-sql-backend’
I’m trying to build the following query:
const query = `
SELECT
_id,
sei,
FROM MY_DATABASE
LEFT JOIN SEC_DATABASE
ON MY_DATABASE._id = SEC_DATABASE._id
WHERE
MY_DATABASE.data >= '${new Date('2024-01-02')}'
AND MY_DATABASE.data <='${new Date('2024-01-03')}'
LIMIT 100
However, this way all data is returned, ignoring the where condition.
Additional information:
It was done this way, as it makes it possible to use the left join and this has helped a lot.