Does anyone know how to pass dates to Prisma.query...
# orm-help
j
Does anyone know how to pass dates to Prisma.queryRaw? If I just write it like this:
SELECT * FROM "Example" WHERE "date" > '2020-10-10'
it works fine. But how to pass the date as variable? I have tried it like this:
_let_ fromStr = dayjs(from).format("YYYY-MM-DD");
`Prisma.queryRaw`SELECT * FROM "Example" WHERE "date" > '${fromStr}'`` and also without the single quotes but it throws “ERROR: invalid input syntax for type date: \“$1\“” each time
1
a
Hey there! Is the
from
variable an instance of
Date
? In that case, try passing it directly into the raw query and let me know if it works.
j
Aah it was that easy, I tried to do it in a too complex way, thanks!
🚀 1